[PHP]Approval 2

Junior Spellweaver
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.
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."; 
 }
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.
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>
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?
 
when u put approve[].. it means ur sending out an array.

on the other end of the script u must be prepared to accept the array. ur still treating it as a normal variable
 
PHP:
UPDATE `service` SET `approved` = '1' WHERE `ID` = '{$id}'"
I thought it was:
PHP:
WHERE `ID` ='$id'
correct me if im wrong
 
i'm not sure.. ughh.

edit: so i guess ppl dont know how to do a simple approve or deny?
ill try googling. lol.
 
Last edited:
Back