SEVIZ Posted March 20, 2009 Share Posted March 20, 2009 I am using this code: <select name='tech' id='tech' tabindex='2'> <option value='select'>TEAM CRONIN</option> <?php // Make a MySQL Connection mysql_connect("localhost", "****", "****") or die(mysql_error()); mysql_select_db("****") or die(mysql_error()); $result = mysql_query("SELECT * FROM tech WHERE TEAM='".CRONIN."'") or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $ID = $row['ID']; echo "<option value=".$ID.">$ID</option>"; } ?> <option value='select'>TEAM DENIS</option> <?php // Make a MySQL Connection mysql_connect("localhost", "****", "****") or die(mysql_error()); mysql_select_db("****") or die(mysql_error()); $result = mysql_query("SELECT * FROM tech WHERE TEAM='".DENIS."'") or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $ID = $row['ID']; echo "<option value=".$ID.">$ID</option>"; } ?> </select> How can I do this but without having to query again each time? I have 12 total of these seperate sections and do not want that many queries. EEK! Thanks for any help as always! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 20, 2009 Share Posted March 20, 2009 See items A), B), and D) (replace reference to "month" name with "team" name) at this link - http://www.phpfreaks.com/forums/index.php/topic,242980.msg1134556.html#msg1134556 Quote Link to comment Share on other sites More sharing options...
SEVIZ Posted March 20, 2009 Author Share Posted March 20, 2009 Thank you for the help but I must be misunderstanding something. Everything I try with this comes out wrong or weird. I know this is probably asking a lot but can you elaborate at all on what the stuff in that code does? So much of it is related to date and such and mine does not have that at all. I am lost trying to figure it out. I apologize. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted March 20, 2009 Share Posted March 20, 2009 First of all, you're make a new connection each time. You could just do: <select name='tech' id='tech' tabindex='2'> $result = mysql_query("SELECT * FROM tech") or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $name = $row['TEAM']; $id = $row['ID']; echo "<option value='$id'>Team $name</option>"; } And put your connection information once at the top of the page. 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.