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 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>"; ?> 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'"); ?> Link to comment https://forums.phpfreaks.com/topic/52567-solved-db-populated-dropdown/#findComment-259389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.