Jump to content

[SOLVED] Can't figure out how to get radio box value?


brent123456

Recommended Posts

$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.

Link to comment
Share on other sites

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"); 

		    		}
                   }
                         

Link to comment
Share on other sites

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???

		    		}
                   }
                         

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.