I wanted to give my admin the power to search professors by name and provide them with a corresponding checkbox for each search result returned to help them select entries that he wants to delete (like we have in phpmyadmin for example). I'm posting the prof_name from a form that leads to this file. (Know there are sql injection holes, but i'll take care of them soon.) This is the php file where i'm showing my search results:
<?php
include('connectionfile.php');
session_start();
if (!isset($_SESSION["useradmin"])) {
header("Location: index.html");
}
else
{
$query = $_POST['prof_name'];
echo "<br><p>";
$res = mysql_query("SELECT * FROM professor WHERE (`prof_name` LIKE '%".$query."%') ") OR die(mysql_error()) ;
$number= mysql_num_rows($res);
echo "<br>No. of results returned: ";
echo "$number";
if($number > 0)
{
echo ( "<br><br><form id='assign' action= 'delconfirm.php' method='post'> <table border='1' cellpadding='8' cellspacing= '6' bgcolor= '#302c21' bordercolor='#158bee' align='center' >" ) ;
echo ("<br><tr><td><center><b>Professor ID</b></td><td><center><b>Professor Name</b></td><td><center><b>Professor Designation</b></td><td><center><b>Experience</b></td><td><center><b>Email ID</b></td><td><center><b>College Name</b></td><td><center><b>Subject Name</b></td><td><center><b>Select for Deleting</b></td></tr>");
while($results = mysql_fetch_array($res))
{
echo ("<tr><td><center>".$results['prof_id']."</td><td><center>".$results['prof_name']."</td><td><center>".$results['designation']."</td><td><center>".$results['experience']."</td><td><center>".$results['prof_email_id']."</td><td><center>".$results['college_name']."</td><td><center>".$results['subject_name']."</td> ");
echo(" <td><center><input type= 'checkbox' name='selected[prof_id]' value= 'false' id='checkbox1' /> </td>");
echo("</p></tr>");
}
echo("</table><br><br><br><center><input type= 'submit' name='delpro' value= 'Delete' /></form>");
}
else
{
echo "<br> No matches found.";
}
mysql_close($id_link);
}
?>
The page i'm leading to is delconfirm.php. I wanted that the entries selected in previous file be deleted and echo the entries that were deleted. But for that i'll have to make sure the prof_ids of the selected entries be passed in this file so i that can delete query on those ids. Don't know what code to write in this file :( can anyone assist me?
Everytime i have a problem solved, another just pops up :/ please help me. Thanks!