...

View Full Version : A listbox Question



briintex1
05-31-2004, 01:36 AM
I have a page that is pulling things out a database like for instance country_name, the name of my table is country...and I have 2 columns called country_ID, and Country_Name;
I have 4 rows called US, Canada, Mexico, and Spain
I was wondering where my error was in displaying the items in the listbox/combo box
I connect to a database in PHPmyAdmin and pull the information out of the database and want to display it in a listbox here is my code
<?php
$db = mysql_connect("localhost", "username", "pw")or die(mysql_error());

mysql_select_db("DatabaseName")or die(mysql_error());

$options = mysql_query("SELECT * FROM country");
$options=mysql_fetch_array($options);

function enhanced_list_box($options){
$sql = "select " . options['id_field'];
$sql .= ", " . $options['value_field'];
$sql .= " from " . $options['table'];

/* append any where criteria to the sql */
if (isset($options['where_statement'])) {
$sql .= " where " . $otpions['where_statement'];

}

/* set the sort order of the list*/

$sql .= " order by " . $options['value_field'];

$result = mysql_query($sql) or die("error in SQL);

echo '<select name="', $options['id_field'], '" size="1">';

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
if ($row[0] == $options['highlight_id']) {
echo '<option value="', $row[0], '" SELECTED>', $row[1], '</option>';
}
}

echo '</select>';

}
?>
<html>
<head
</head>
<title><? echo $obj[1] ?></title>

<? enhanced_list_box(array(
'table' => 'country',
'id_field' => 'country_id',
'value_field' => 'country_name',
hightlight_id = 4));
?>
<body>
</body>
</html>
this is my error
Parse error: parse error in /home/briintex1/public_html/index.php on line 10

firepages
05-31-2004, 03:32 AM
$sql = "select " . options['id_field'];

should be

$sql = "select " . $options['id_field'];

briintex1
05-31-2004, 04:36 AM
thanks that was it...I should have caught that..
thanks again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum