Petty_Crim Posted June 29, 2007 Share Posted June 29, 2007 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 Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 29, 2007 Share Posted June 29, 2007 try this $m=fldb->name; Quote Link to comment Share on other sites More sharing options...
Petty_Crim Posted June 29, 2007 Author Share Posted June 29, 2007 try this $m=fldb->name; Yep fixed that but it still not working. Quote Link to comment Share on other sites More sharing options...
suma237 Posted June 29, 2007 Share Posted June 29, 2007 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>"; } } Quote Link to comment Share on other sites More sharing options...
Petty_Crim Posted June 29, 2007 Author Share Posted June 29, 2007 The loop isn't executing for some reason. I did a similar loop earlier on and it worked. Anyone know whats stopping this from working? Quote Link to comment Share on other sites More sharing options...
Petty_Crim Posted June 29, 2007 Author Share Posted June 29, 2007 Anyone know? Quote Link to comment Share on other sites More sharing options...
no_one Posted June 29, 2007 Share Posted June 29, 2007 Might want to check count returned.. the loop wouldn't execute if no results were returned from the db. Quote Link to comment Share on other sites More sharing options...
Petty_Crim Posted June 29, 2007 Author Share Posted June 29, 2007 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? Quote Link to comment Share on other sites More sharing options...
Petty_Crim Posted June 29, 2007 Author Share Posted June 29, 2007 This is really odd I try using $result7 again and now it doesn't work lol. Cant use things twice? Quote Link to comment 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.