- Joined
- Dec 2, 2006
- Messages
- 198
- Reaction score
- 0
So recently, I've been having no troubles I think with my scripting. However, now, i have this little problem.
i changed a check box to a drop down box now, and i'm really excited for it to try working.
however, due to my lack of php knowledge, ive had trouble.
this was what i used for a check box. how can i edit it so that i takes the information from approve or deny?
i thought at first that i could just change the id name to 1 and 2 and get it like that. anyone have any ideas?
PHP:
while($row = mysql_fetch_array( $query )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['action'];
echo "</td>";
echo "<td>";
echo $row['hours'];
echo "</td><td>";
$id = $row['id'];
echo "<form action=\"approve.php\" method=\"post\"><select name=\"approve[]\"><option value =\"$id1\">Approve</option><option value =\"$id2\">Deny</option></select>";
echo "</td></tr>";
}
echo "</table>";
echo "<input type=\"submit\" name=\"Approve\" value=\"Approve\"></form>";
} else {
echo "Access Denied.";
}
however, due to my lack of php knowledge, ive had trouble.
PHP:
<?php
if (isset($_POST['approve'])) {
$id = $_POST['approve'];
mysql_connect("localhost", "ashin951_keydb", "keydb") or die(mysql_error());
mysql_select_db("ashin951_keydb") or die(mysql_error());
$ticked = $_POST['approve'];
foreach($ticked as &$id) {
mysql_query("UPDATE `service` SET `approved` = '1' WHERE `ID` = '{$id}'") or die(mysql_error());
}
echo "Successfully Approved.";
unset($id);
} else {
echo "Access Denied.";
}
?>
<title>Approval</title>
i thought at first that i could just change the id name to 1 and 2 and get it like that. anyone have any ideas?