php(ezsql)循环打印错误的值

时间:2017-08-07 20:10:08

标签: php mysql ezsql

我讨厌寻求帮助,看起来应该是显而易见但我在这一点上有点迷失:

我正在尝试设置搜索学生姓名的代码,或者只显示最近100个学生文件的列表。

列表代码工作正常,但每当我尝试运行搜索时,它会返回正确的学生姓名,而每个学生的唯一ID将始终是错误的数字。例如:bob,ID:23,Jane,ID:23,Jill:ID:23 - 当结果真的应该是bob时,ID:23,Jane,ID:24,Jill:ID:25

我错过了什么?

<?php
if($_POST['Student_Name'])
    {
    // Select multiple records from the database and print them out..
    $Student_Name = $_POST['Student_Name']; 

    $users = $db->get_results("select * FROM Students WHERE Name LIKE '%$Student_Name%' order by ID DESC");
   echo "Search is on";


    } else {

    $users = $db->get_results("SELECT * FROM Students order by ID DESC LIMIT 100");
    echo "No Search engaged <HR>";
    }


    foreach ( $users as $user )   
    {
        echo "<div class=\"row\"><div class=\"col-sm-4\">";
        echo $user->Name;       
        echo "</div>";
        echo "<div class=\"col-sm-8\">";    
        echo "<form action=\"Students_Profile.php\"  method=\"post\" ><input type=\"hidden\" name =\"Student_ID\" value=".$user->ID." /><input type=\"submit\" value=\"View Student Profile\" /></form></div>";         
    } ?>

0 个答案:

没有答案