View Full Version : Problem with radio buttons

08-22-2009, 03:12 PM
Hello all ,

here is some code of my form.

<form action="mypage.php" method="post" name="form1" >


$sql = "SELECT * FROM `mytable` WHERE `Cat_ID`='116' ";

$res = mysql_query ($sql,$link) or die(mysql_error());

while($row = mysql_fetch_array($res))



<table width="100%" border="1" cellspacing="0" cellpadding="0">
<td width="71%" height="49">

<strong style="color: #0000FF"> Name :- </strong> <? echo "<span class=sidetxt> $row[Name]</span><br>";?>

<strong style="color: #0000FF"> Email :- </strong> <? echo "<span class=sidetxt> $row[Email]</span><br>";?>

<strong style="color: #0000FF"> Description :- </strong><? echo "<span class=descriptiontext> $row[Description]</span><br>";?>


<td width="29%" align="center">

<input name="id" type="hidden" value="<?=$row['ID']?>">
<input name="cat_id" type="hidden" value="<?=$row['cat_ID']?>">
<input name="name" type="hidden" value="<?=$row['Name']?>">
<input name="email" type="hidden" value="<?=$row['Email']?>">
<input name="description" type="hidden" value="<?=$row['description']?>"> <br />

<Input type="radio" name ="myradio" value= "hold" checked="checked"/><strong style="color:#990000"> Hold </strong>

<Input type="radio" name ="myradio" value= "approve" /> <strong> Approve </strong>

<Input type="radio" name ="myradio" value= "delete" /> <strong> Delete </strong></p>



<? } ?>

<input name="submit" type="submit" class="footerlink" value="Submit Selected" >


In my form i am using a query to fetch all rows of record of the given ID.

What i want is that my first option radio button " Hold " to be checked
bydefault in all the rows retrieved from DB.

and Approve and Delete actions can also be performed for each rows seperately by selecting their options & submitting.

I think a loop for count rows & check radio can be applied but not sure
in php or javascript & how,

Please help me how the Hold option can get checked bydefault
for each no. of rows fetched from DB.

Thanks & Regards.