This is what have for that portion
Code: Select all
echo "<form name=\"updateSchools\" method=\"post\" action=\"".$admin_file.".php\">"
."<input type=\"hidden\" name=\"op\" value=\"updateSchools\">";
echo '<table border="1" cellspacing="0" cellspadding="9">';
echo '<tr><td colspan="2" align="center"><span style="font-size:14;"><b>Update Schools</b></span></td></tr>';
echo '<tr><td><span style="font-size:14;">Delete </span></td><td><span style="font-size:14;"> Schools Name </span></td></tr>';
$schoolsResult = $db->sql_query("SELECT * FROM Schools ORDER BY SchoolsID");
while ($schoolsRow = $db->sql_fetchrow($schoolsResult)) {
$id = $schoolsRow['SchoolsID'];
$name = $schoolsRow['SchoolsName'];
echo '<tr><td align="center"><input type="checkbox" name="delete[]" value="yes"></td>';
echo '<td><input type="text" name="name[]" value="'.$name.'"></td>';
echo '<input type="hidden" name="id[]" value="'.$id.'">';
$id = '';
$name = '';
$school_num ++;
}
echo '<input type="hidden" name="num" value="'.$school_num.'">';
echo '<tr><td colspan="3" align="right"><input type="submit" value="update"</td></tr>';
echo '</table>';
echo '<br><br><br>';
echo '</td></tr>';
echo '</form>';Code: Select all
case "updateSchools":
updateSchools($delete, $name, $id, $num);
break;Code: Select all
function updateSchools($delete, $name, $id, $num) {
global $language, $admin, $prefix, $db, $admin_file;
$count = 0;
while ($count < $num) {
if ($delete[$count] == 'yes') {
echo ("DELETE FROM Schools WHERE SchoolsID = ".$id[$count].""); // i have it echo so that i can fix it
echo "<br>";
} else {
echo ("UPDATE Schools SET SchoolsName='".$name[$count]."' WHERE SchoolsID = ".$id[$count]."");
echo "<br>";
}
$count++;
}
//Header("Location: ".$admin_file.".php?op=dropdownOptions"); // once it is working correctly, it will redirect to the designated page.
}But when a box is checked, then for the update section, it reads those checks from the first to last.
EXAMPLE::
4 results from the query
-delete-name
1 ) [ ] - Yale
2 ) [ ] - Havard
3 ) [X] - UNLV
4 ) [X] - BYU
(rough layout attempt...
UNLV and BYU should be set to delete right?
Well when the queries print, it says that Yale and Harvard should delete
If just Havard is checked to delete, the query says Yale will be deleted...
And if Yale is checked to delete, then the query says Yale will be deleted...
Please, If anyone understands why that is, it will VERY much appreciated...
Thanks in advance