update table with radio button

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
freddyvorhees
Forum Newbie
Posts: 3
Joined: Mon Aug 02, 2010 9:02 am

update table with radio button

Post 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.
User avatar
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

Post by AbraCadaver »

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

Post 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
}
?>
User avatar
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

Post by AbraCadaver »

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.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: update table with radio button

Post 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.
Post Reply