Hi,
I have been working on this function for a little while and can\'t work out why it is displaying a blank drop down list.
I have used the code without the database stuff and it works fine. I would like to know why it isn\'t working when I get the information from a database table.
function category($default)
{
$category_array(\'Please-Select-One\');
include \"mysqlconnectinfo.php\";
// Create Connection
$connection = mysql_connect($dbhostname,$dbusername,$dbpassword) or die(\"Couldn\'t make connection.\");
//Select Database
$db = mysql_select_db(\"$dbbase\", $connection) or die(\"Couldn\'t select database\");
// create SQL statement
$sql = \"SELECT * FROM Category\";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection) or die(\"Couldn\'t execute query.\");
while ($row = mysql_fetch_array($sql_result))
{
$Name = ucwords($row[\"Name\"]);
array_push($category_array, \"$Name\");
}
$output = \"\";
$a_item = 0;
while (list($val,$value) = each($category_array))
{
$a_item = $val + 1;
if ($value == $default)
{
$selected = \" selected\";
}
else
{
$selected = \"\";
}
$output .= \"<option$selected>$value</option>\\n\";
}
return $output;
}
Thanks in advance.
Yours Sincerely,
Anthony Irwin