brent123456 Posted July 5, 2007 Share Posted July 5, 2007 $output .= '<td class="highlight">Accept:<input type="radio" name=' . $row['trade_id'] . 'value="accepted" />Decline:<input type="radio" name=' . $row['trade_id'] . 'value="accepted" /></td>'; I am not sure how I can get this value on my submit page? How can I know which radio box was used the accepted box or the Decline box. It is printing this out for each trade that id in the database. There is a set of two radio buttons for each trade row. I then want to go though each set of two radio buttons on the submit page and update depending on which one was selected. Please help thanks. Quote Link to comment Share on other sites More sharing options...
brent123456 Posted July 5, 2007 Author Share Posted July 5, 2007 opps sorry Quote Link to comment Share on other sites More sharing options...
Barand Posted July 5, 2007 Share Posted July 5, 2007 opps sorry Does that mean you solved it? Quote Link to comment Share on other sites More sharing options...
brent123456 Posted July 6, 2007 Author Share Posted July 6, 2007 Ha ha.. nope I just double posted. I did figure it out though here is the code.. foreach($_POST as $name=>$val) { if ($val == 'accepted') { $query = "UPDATE my_table SET i_accepted='1' WHERE the_id='$name'"; $result = mysql_query($query) or die("Error Processing $name"); } } Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 Ha ha.. nope I just double posted. I did figure it out though here is the code.. foreach($_POST as $name=>$val) { if ($val == 'accepted') { $query = "UPDATE my_table SET i_accepted='1' WHERE the_id='$name'"; $result = mysql_query($query) or die("Error Processing $name"); what about that??? } } Quote Link to comment Share on other sites More sharing options...
Barand Posted July 6, 2007 Share Posted July 6, 2007 It's easier to name the radio buttons "accepted" and give each a value = rec id Then it's just a matter of getting the id to be updated from $_POST['accepted'] Quote Link to comment Share on other sites More sharing options...
brent123456 Posted July 6, 2007 Author Share Posted July 6, 2007 Hi Barand, Could you give me an example. What would be the best way to loop though them with foreach? Thanks. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 6, 2007 Share Posted July 6, 2007 You don't need to loop through radio buttons. Only one can be selected and that's the value that you will get. <?php if (isset($_POST['accepted'])) { echo 'Accepted : ' . $_POST['accepted']; } ?> <form method='post'> <?php for ($rb=1; $rb<=5; $rb++) { echo "<input type='radio' name='accepted' value='$rb'> Button $rb <br/>"; } ?> <input type='submit' name='submit' value='Submit'> </form> Quote Link to comment Share on other sites More sharing options...
brent123456 Posted July 7, 2007 Author Share Posted July 7, 2007 I thank you for your help Barand . Next time this comes up I this will be very helpful. Quote Link to comment 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.