Listbox problem
Posted: Fri Aug 29, 2008 8:02 am
I'm new to PHP, and creating a form with a listbox that is populated from a mySQL table.
I know this is fairly common, but I'm having a problem getting the listbox to populate;
Here is the code I'm using
Database connection php
Listbox code
The select option is appearing with no problems, but the listbox isn't populating with the information from the database, can anybody see the problem?
I know this is fairly common, but I'm having a problem getting the listbox to populate;
Here is the code I'm using
Database connection php
Code: Select all
<?php
$dbServer="localhost";
$username="username";
$password="password";
$database="database";
//make database connection
$conn = mysql_connect($dbServer,$username,$password);
@mysql_select_db("$database") or die("unable to select database".mysql_error());
?>Code: Select all
<label>Resource Required
<select name="Resource">
<option value=>--Select--</option>
<?
//get records from database(table resource)
$list=mysql_query("SELECT * FROM Resource");
//show records by while loop
while($row_list=mysql_fetch_array($list))
?>
<optionvalue="<? echo $row_list[Res_ID]; ?>" </option>
</select>