Forum Moderators: coopster

Message Too Old, No Replies

passing values from radio buttons to a hyperlink

         

nicuz

8:55 pm on Apr 8, 2006 (gmt 0)



Here's my code:

echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>";
echo "<tr><td width='20'></td>
<td>Ad Name</td></tr>";

while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
echo "<tr><td><input name='vAd' type='radio' value='$adID'></td>
<td>{$row['adName']}</td></tr>";
}
echo "<tr><td colspan='2' width='10'>
<table cellspacing='10' border='0' cellpadding='0' width='100%'>
<tr><td><a href='edit_add.php?id=$adID'>Edit</a></td></tr></table>
</td></tr></table>";

I would like to pass the value $adID from the radio buttons to this link here: <a href='edit_add.php?id=$adID'>Edit</a>
But no matter what radio button I choose, when I click the Edit link, the ID doesn't change. Any sugestions? Thanks.

dreamcatcher

10:51 pm on Apr 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

You are not using the correct variable. Your field has the name of 'vAd', so this is what you must access:

echo "<a href='edit_add.php?id=$vAd'>";

or if register globals are off:

echo "<a href='edit_add.php?id='".$_POST['vAd']."'>";

dc

nicuz

12:03 am on Apr 9, 2006 (gmt 0)



That did not work...

However, if I put all my code into the while structure like this:

while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{

echo "<table cellspacing='10' border='0' cellpadding='0' width='100%'>";
echo "<tr><td width='20'></td>
<td>Ad Name</td></tr>";

extract($row);
echo "<tr><td><input name='vAd' type='radio' value='$adID'></td>
<td>{$row['adName']}</td></tr>";

echo "<tr><td colspan='2' width='10'>
<table cellspacing='10' border='0' cellpadding='0' width='100%'>
<tr><td><a href='edit_add.php?id=$adID'>Edit</a></td></tr></table>
</td></tr></table>";
}

it will work, the id will change but it will also generate a new table everytime, and I don't want this.