Jump to content

[SOLVED] db populated dropdown


Crustyfur

Recommended Posts

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  ;D

Link to comment
https://forums.phpfreaks.com/topic/52567-solved-db-populated-dropdown/
Share on other sites

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.