Page 1 of 1

update table with radio button

Posted: Mon Aug 02, 2010 9:17 am
by freddyvorhees
this is what im trying to do;
ill loop the rows in my table and the radio buttons beside them;
the user will have to choose the row to update using the radio button;

my problem is how do i retrieve the index of the row selected using the radio button.
I can't individualy set the value for the radio buttons cause im using a loop.

any suggestions? thank you.

Re: update table with radio button

Posted: Mon Aug 02, 2010 9:40 am
by AbraCadaver
Show your loop.

Re: update table with radio button

Posted: Mon Aug 02, 2010 9:56 am
by freddyvorhees
<?php
for ($i = 0; $i < $tablerow; $i++ )
{
?>
<form method = "post" action = "updatepage">
<input type = "radio" name = "row[]" value = "idont know what to put">
output my a row
</form>
<?php
}
?>

Re: update table with radio button

Posted: Mon Aug 02, 2010 10:27 am
by AbraCadaver
Depends on what "output my a row" is. Where is the info from the database?

Re: update table with radio button

Posted: Mon Aug 02, 2010 3:28 pm
by califdon
freddyvorhees wrote:<?php
for ($i = 0; $i < $tablerow; $i++ )
{
?>
<form method = "post" action = "updatepage">
<input type = "radio" name = "row[]" value = "idont know what to put">
output my a row
</form>
<?php
}
?>
Radio buttons, by definition, allow a user to select just one (the others will automatically deselect), at which point, the value of the variable identified by the name of all the buttons (which must be the same for all of them) will be the value you have assigned for that button. This might be a URL, or it might be an amount of money, or it might just be the value of your loop variable ($i) in your case. In any case, I don't think "row[]" is a valid name for a button element, it needs to be something like "price" or "url" or something, whatever these rows represent.