Jump to content

Fill Drop Down Box with Field Names


Petty_Crim

Recommended Posts

I'm having trouble trying to fill a drop down box with the names of fields. Basically I'm making a db for a team and I got various fields including the names of players who might play in it. In my loop I exclude thenone player fields and then add the player fields to a drop down box so I should end up with a drop down box of all the players. My problem is its not working

This is my code I'm using atm:

$result3=mysql_query("SELECT * FROM bf2stats WHERE match_id='$match_idP'");

echo "<td>";
echo "<select name='player_list'>";
echo "<option value='-1'>(Change Player)</option>";
while($fldb = mysql_fetch_field($result3))
{
if ($fldb->name!='match_id' && $fldb->name!='match_name' && $fldb->name!='score' && $fldb->name!='result' && $fldb->name!='date')
    {
		$m=$fldb->name;
		echo "<option value=$m>$m</option>";
    }
}
echo "</select>";
echo "</td>";

 

My table looks similar to this

match_idmatch_name

[/td]score

date John Fred Larry

1Pirates Team3-0Win12/12/2006010

Link to comment
Share on other sites

check the loop is executing or not?

 

while($fldb = mysql_fetch_field($result3))

{

if ($fldb->name!='match_id' && $fldb->name!='match_name' && $fldb->name!='score' && $fldb->name!='result' && $fldb->name!='date')

    {

echo"im here";

$m=$fldb->name;

echo "<option value=$m>$m</option>";

    }

}

Link to comment
Share on other sites

Ok this is weird i made a result called $result7 with exactly the same stuff as $result3 and used that in the loop and presto it works.

 

So now I'm wondering does looping more then once on a query have an effect? In my code I've used $result3 once before in a fetch field thing, so maybe I'm only allowed to do this once?

Link to comment
Share on other sites

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.