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.
update table with radio button
Moderator: General Moderators
-
freddyvorhees
- Forum Newbie
- Posts: 3
- Joined: Mon Aug 02, 2010 9:02 am
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: update table with radio button
Show your loop.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
freddyvorhees
- Forum Newbie
- Posts: 3
- Joined: Mon Aug 02, 2010 9:02 am
Re: update table with radio button
<?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
}
?>
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
}
?>
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: update table with radio button
Depends on what "output my a row" is. Where is the info from the database?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: update table with radio button
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.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
}
?>