Jump to content

[SOLVED] Pulling from database in a form, beginner


tj71587

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.