I hate asking for help with something that seems like it should be obvious but I'm a little lost on this one:
I'm trying to set up code that will either search for a student's name, or just display a list of the most recent 100 student files.
The list code works fine, but whenever I try to run a search, it comes back with the correct student name, while the unique ID for each student will always be the wrong number. For example: bob, ID: 23, Jane, ID: 23, Jill: ID: 23 - when the results should really be bob, ID: 23, Jane, ID: 24, Jill: ID: 25
What am I missing?
<?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>";
} ?>