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. Link to comment https://forums.phpfreaks.com/topic/68211-solved-pulling-from-database-in-a-form-beginner/ 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>'; Link to comment https://forums.phpfreaks.com/topic/68211-solved-pulling-from-database-in-a-form-beginner/#findComment-342922 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? Link to comment https://forums.phpfreaks.com/topic/68211-solved-pulling-from-database-in-a-form-beginner/#findComment-342925 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 Link to comment https://forums.phpfreaks.com/topic/68211-solved-pulling-from-database-in-a-form-beginner/#findComment-342984 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. Link to comment https://forums.phpfreaks.com/topic/68211-solved-pulling-from-database-in-a-form-beginner/#findComment-343095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.