tj71587 Posted September 6, 2007 Share Posted September 6, 2007 Hey Im very new to php, and I am trying to make a select menu in php, where the select menu pulls fields from a database. Heres what I am using, can anyone tell me if I am even close? include 'includes/config.php' include 'includes/opendb.php' $query = "Select * FROM Companies"; $result = mysql_query($query); while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $company=$r["Company"]; //display the row echo "<option value="$company">$company</option>"; } include 'includes/closedb.php' I also tried removing the quotes around company in the value field and that didnt help. Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 6, 2007 Share Posted September 6, 2007 You're going to get errors with that. Try: echo "<option value=\"$company\">$company</option>"; Or: echo '<option value="'.$company.'">'.$company.'</option>'; Quote Link to comment Share on other sites More sharing options...
tj71587 Posted September 6, 2007 Author Share Posted September 6, 2007 Thanks, Notepad ++ recognized it in its syntax coloring, but I still get nothing in the web browser. Any other suggestions? Quote Link to comment Share on other sites More sharing options...
uwannadonkey Posted September 6, 2007 Share Posted September 6, 2007 include 'includes/config.php' include 'includes/opendb.php' both of those, have no ; at the end Quote Link to comment Share on other sites More sharing options...
tj71587 Posted September 6, 2007 Author Share Posted September 6, 2007 Thanks for the help, I feel like an idiot. 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.