Hi All
I'm a noob and wanted to show records from my db with one field using radio buttons. Problem is that I can't get the values from the table to check the appropriate radio button.
Any help MUCH appreciated
Cheers :)
[php]
$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";
while($show = mysql_fetch_arr ay( $result )) {
// Print out the contents of each row into a table
echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";
/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." 'IsSponsored'\" value=\"1\" ".$sponsored."> ";
echo "</td> <td>";
/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." 'IsSponsored'\" value=\"0\" ".$notsponsored .">";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}[/php]
Use the appropriate code tags around your code - moderator
I'm a noob and wanted to show records from my db with one field using radio buttons. Problem is that I can't get the values from the table to check the appropriate radio button.
Any help MUCH appreciated
Cheers :)
[php]
$sponsored = ('IsSponsored' == 1)?"checked" : "";
$notsponsored = ('IsSponsored' == 0)?"" : "checked";
while($show = mysql_fetch_arr ay( $result )) {
// Print out the contents of each row into a table
echo "<tr> <td>";
echo $show['ChildID'];
echo "</td> <td >";
echo $show['givenName'];
echo "</td> <td>";
echo $show['gender'];
echo "</td> <td>";
echo $show['countryName'];
echo "</td> <td>";
echo $show['favouritePlay'];
echo "</td> <td>";
/*this box checked if IsSponsored = 1*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." 'IsSponsored'\" value=\"1\" ".$sponsored."> ";
echo "</td> <td>";
/*this box checked if IsSponsored = 0*/
echo "<input type=\"radio\" name=\"".$show['ChildID']." 'IsSponsored'\" value=\"0\" ".$notsponsored .">";
echo "</td> <td>";
echo $show['dateOfBirth'];
echo "</td> </tr>";
}[/php]
Use the appropriate code tags around your code - moderator
Comment