Jump to content

[SOLVED] Radio Button checked


timmah1

Recommended Posts

Why does this not show this as being checked?

 

<?php
$sport = "nfl";
$team02 = "69";
$favorite = "69&sports=nfl";

$str = $favorite;
$parts = explode('&', $str);
$fav = $parts[0];

require("config.php");
$sql="SELECT * FROM $sport WHERE id = '$fav' AND size = 'lg'";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
		if($numrows == 0){
			echo "<div id='txtHint'>";
			echo "NO-Favorite:<br /><input type=\"radio\" name=\favorite\" value=\"$team02&sports=$sport\" />";
			echo "<p><img src=\"images/$sport/$row1[image]\" alt=\"$row1[team]\" width=\"150\" /></p>";
			echo "<h2>$row1[team]</h2></div>";
		}
		else {
			while($row1 = mysql_fetch_array($result)){
		//if($fav == $row1['id']){
				//echo "
			echo "<div id='txtHint'>";
			echo "YES-Favorite:<br /><input type=\"radio\" name=\"favorite\" value=\"$fav&sports=$sport\" checked=\"checked\" />";
			echo "<p><img src=\"images/$sport/$row1[image]\" alt=\"$row1[team]\" width=\"150\" /></p>";
			echo "<h2>$row1[team]</h2></div>";
			}
		}
?>

 

It echoes out the YES, but it won't show the radio button as being checked.

 

How can something so simple create so much havoc!

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/170687-solved-radio-button-checked/
Share on other sites

i'm not really sure... but try this:

<?php
$sport = "nfl";
$team02 = "69";
$favorite = "69&sports=nfl";

$str = $favorite;
$parts = explode('&', $str);
$fav = $parts[0];

require("config.php");
$sql="SELECT * FROM $sport WHERE id = '$fav' AND size = 'lg'";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
         if($numrows == 0){
            echo "<div id='txtHint'>";
            echo "NO-Favorite:<br /><input type=\"radio\" name=\favorite\" value=\"$team02&sports=$sport\" />";
            echo "<p><img src=\"images/$sport/$row1[image]\" alt=\"$row1[team]\" width=\"150\" /></p>";
            echo "<h2>$row1[team]</h2></div>";
         }
         else {
            while($row1 = mysql_fetch_array($result)){
         //if($fav == $row1['id']){
               //echo "
            echo "<div id='txtHint'>";
            echo "YES-Favorite:<br /><input type='radio' name='favorite' value='".$fav."&sports=".$sport."' checked='checked' />";
            echo "<p><img src=\"images/$sport/$row1[image]\" alt=\"$row1[team]\" width=\"150\" /></p>";
            echo "<h2>$row1[team]</h2></div>";
            }
         }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.