Guest PcGamerz13 Posted March 21, 2006 Share Posted March 21, 2006 It only shows 1 Gamer_Tag from the database instead of all the Gamer Tags. Can someone fix it plz.I want all the Gamer Tags into one Option plz help[code]$sql3="SELECT * FROM clan_members";$mysql_result3=mysql_query($sql3);$num_rows3=mysql_num_rows($mysql_result3);while ($row3=mysql_fetch_array($mysql_result3)){$Gamer_Tag=$row3["Gamer_Tag"];}echo "<center><font size='4'>Report Member</font></center>";?><form method="POST" action="Report_Member.php?Report_Member=Yes"><center>Gamer Tag: <select size="1" name="Reported_Gamer_Tag"><option><? echo $Gamer_Tag; ?></option></select></center><center>Reason: <textarea rows="2" name="Reason" cols="20"></textarea></center><center><input type="submit" value="Submit" name="B1"></form>[/code] Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 21, 2006 Share Posted March 21, 2006 [!--quoteo(post=356812:date=Mar 21 2006, 01:04 AM:name=PcGamerz13)--][div class=\'quotetop\']QUOTE(PcGamerz13 @ Mar 21 2006, 01:04 AM) [snapback]356812[/snapback][/div][div class=\'quotemain\'][!--quotec--]It only shows 1 Gamer_Tag from the database instead of all the Gamer Tags. Can someone fix it plz.I want all the Gamer Tags into one Option plz help[code]...while ($row3=mysql_fetch_array($mysql_result3)){$Gamer_Tag=$row3["Gamer_Tag"];}...[/code][/quote]here's a problem. you re-assign the value of $Gamer_Tag every time. if you want $Gamer_Tag to be an array, so you can just store all the values from the database, just use $Gamer_Tag[] instead:[code]...$Gamer_Tag = array();while ($row3=mysql_fetch_array($mysql_result3)){$Gamer_Tag[]=$row3["Gamer_Tag"];}...[/code]and then for your dropdown/menu, use:[code]foreach ($Gamer_Tag as $tag){ echo '<option>'.$tag.'</option>';}[/code] Quote Link to comment Share on other sites More sharing options...
Guest PcGamerz13 Posted March 21, 2006 Share Posted March 21, 2006 i got this code now and all it shows in the drop down is Array. How do you make this code show the whole list of the Gamer Tags in the table?[code]$sql3="SELECT * FROM clan_members";$mysql_result3=mysql_query($sql3);$num_rows3=mysql_num_rows($mysql_result3);$Gamer_Tag = array();while ($row3=mysql_fetch_array($mysql_result3)){$Gamer_Tag[]=$row3["Gamer_Tag"];}?><form method="POST" action="Report_Member.php?Report_Member=Yes"><center>Gamer Tag: <select size="1" name="Reported_Gamer_Tag"><option><? echo $Gamer_Tag; ?></option></select></center><center>Reason: <textarea rows="2" name="Reason" cols="20"></textarea></center><center><input type="submit" value="Submit" name="B1"></form>[/code] Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 21, 2006 Share Posted March 21, 2006 whoops sorry i may have added to my post after you first read it. use the 'foreach' command (check my post above) which will just cycle through each item in the array and make a dropdown item from itCheersMark[b]EDIT:[/b] or more specifically:[code]<select size="1" name="Reported_Gamer_Tag"> <?php foreach ($Gamer_Tag as $tag) { echo '<option>'.$tag.'</option>'; } ?></select>[/code]hope that helps 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.