tobeyt23 Posted September 4, 2007 Share Posted September 4, 2007 I have a list of messages and would like to have a radio used to select the one to make active, then when the user submits the db is updated to reflect the radio selected. Currently this is not happening any suggestions on how to fix this: <?php // update status settings if ($submit == "Update Status") { if (isset($emergencyid)) { for ($i = 0; $i < count($emergencyid); $i++) { $query = "UPDATE $tableMessage SET status=" . $status[$i]) . " WHERE emergencyid=" . $emergencyid[$i]; $res = mysql_query($query); if (mysql_error()) { doStop("Message Status Failed", $query); } } } } ?> <tr bgcolor="#1b3d6a"> <td valign="top" align="center" bgcolor="#ffffff"><input type="hidden" name="emergencyid[]" value="3"><label for="status[]"></label><input type="radio" name="status[]" id="status[]" value="1" checked class="admin"></td> <td valign="top" bgcolor="#ffffff">Test</td> <td valign="top" bgcolor="#ffffff">09-04-2007</td> </tr> <tr bgcolor="#1b3d6a"> <td valign="top" align="center" bgcolor="#f5f5f5"><input type="hidden" name="emergencyid[]" value="1"><label for="status[]"></label><input type="radio" name="status[]" id="status[]" value="1" class="admin"></td> <td valign="top" bgcolor="#f5f5f5">A Breaking News Message can go here, or not, at the admin's preference.</td> <td valign="top" bgcolor="#f5f5f5">08-14-2007</td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/ Share on other sites More sharing options...
darkfreaks Posted September 4, 2007 Share Posted September 4, 2007 Try <?php die("Message Status Failed". mysql_error($query)) ;?> Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/#findComment-341451 Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 Currently this is not happening... What is happening? Do you have multiple sets of radio buttons; Can the use ever click more than one radio button to submit? I'm just curious because you don't show that they can and if that is the case, there is no reason to use an array. Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/#findComment-341452 Share on other sites More sharing options...
tobeyt23 Posted September 4, 2007 Author Share Posted September 4, 2007 No they can only select one at a time and i wanted so if they select a different one then currently selected it updates the rest in the db to not active. Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/#findComment-341465 Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 If they can only select one, you don't need to use an array for the names in your form. It would be easier to troubleshoot if I knew what was happening in place of what you want to happen. Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/#findComment-341501 Share on other sites More sharing options...
tobeyt23 Posted September 4, 2007 Author Share Posted September 4, 2007 What is happening is if i select the last on the first is updated as active not the last one if i select the first it updates correctly. Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/#findComment-341507 Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 I really don't understand that, but it might be because you are using the arrays for no reason. Try it with normal variable names. Quote Link to comment https://forums.phpfreaks.com/topic/67933-for-help/#findComment-341515 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.