Jump to content

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

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'");
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.