timmah1 Posted August 17, 2009 Share Posted August 17, 2009 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 More sharing options...
AviNahum Posted August 17, 2009 Share Posted August 17, 2009 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>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/170687-solved-radio-button-checked/#findComment-900220 Share on other sites More sharing options...
timmah1 Posted August 17, 2009 Author Share Posted August 17, 2009 no. That don't show as checked either Link to comment https://forums.phpfreaks.com/topic/170687-solved-radio-button-checked/#findComment-900229 Share on other sites More sharing options...
timmah1 Posted August 17, 2009 Author Share Posted August 17, 2009 I eliminated the radio button for a select menu. Works better now Thanks for your help Link to comment https://forums.phpfreaks.com/topic/170687-solved-radio-button-checked/#findComment-900239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.