Crustyfur Posted May 22, 2007 Share Posted May 22, 2007 Hi Guys, I have a problem with script below. First query works a treat, populating drop down and making the relevant entry default. For some reason the second drop down refuses to default. <?php list($fid,$teamid,$fdate,$ftime,$fopp,$ftid,$ffor,$fagg) = $db->sql_fetchinto("SELECT fid, teamid, fdate, fdate, fopp, ffor, fagg, ftid FROM ".$prefix."_fixtures WHERE fid= '$fid'"); $teams="<option> -- Select a Team --</option>"; $result = $db->sql_query("SELECT * FROM hh_teams ORDER BY teamid ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["teamid"]==$teamid) $selected = " selected=\"selected\""; $teams.="<option$selected value=\"".$row["teamid"]."\">".$row["team"]."</option>"; } $fixturetype="<option> -- Select a Fixture Type --</option>"; $result = $db->sql_query("SELECT * FROM hh_fixtures_type ORDER BY ftid ASC"); while($row = $db->sql_fetchrow($result)) { $selected=""; if($row["ftid"]==$ftid) $selected = " selected=\"selected\""; $fixturetype.="<option$selected value=\"".$row["ftid"]."\">".$row["ftype"]."</option>"; } ?> And the query in the form: <?php echo "<select id=\"teamid\" name=\"teamid\">$teams</select>"; echo "<select id=\"ftype\" name=\"ftype\">$fixturetype</select>"; ?> So $teams works but $fixturetype doesn't. It maybe be obvious to spot by my eyes are hurting now Quote Link to comment https://forums.phpfreaks.com/topic/52567-solved-db-populated-dropdown/ Share on other sites More sharing options...
Crustyfur Posted May 22, 2007 Author Share Posted May 22, 2007 just amended a minor error: <?php echo "<select id=\"teamid\" name=\"teamid\">$teams</select>"; echo "<select id=\"ftid\" name=\"ftid\">$fixturetype</select>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52567-solved-db-populated-dropdown/#findComment-259371 Share on other sites More sharing options...
Crustyfur Posted May 22, 2007 Author Share Posted May 22, 2007 My bad, it was this lines fault. list(...) didnt match the sql. doh <?php list($fid,$teamid,$fdate,$ftime,$fopp,$ftid,$ffor,$fagg) = $db->sql_fetchinto("SELECT fid, teamid, fdate, fdate, fopp, ffor, fagg, ftid FROM ".$prefix."_fixtures WHERE fid= '$fid'"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/52567-solved-db-populated-dropdown/#findComment-259389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.