main.html contains the following code and consists of a dropdown that i want to pull some database records into by calling the function fillCategory() contained in list.php
Content on main.html
**************************
**************************
Code: Select all
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Page Title</title>
<script language="javascript" src="list.php"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000" onload="fillCategory();">
<FORM name="drop_list" action="yourpage.php" method="POST" >
<SELECT NAME="Category" >
<Option value="">Category</option>
</SELECT>
</form>
</body>
</html>
**********************
**********************
Code: Select all
<?php
require_once('mysqli_connect.php');
echo "
function fillCategory(
";
$q="select * from category";
echo mysqli_error($dbc);
$r=@mysqli_query($dbc,$q);
while($row=mysqli_fetch_array($r,MYSQLI_ASSOC)){
echo "addOption(document.drop_list.Category, '$row[cat_id]', '$row[category]');";
}
?>
Code: Select all
function fillCategory( addOption(document.drop_list.Category, '1', 'Sport');addOption(document.drop_list.Category, '2', 'Music');addOption(document.drop_list.Category, '3', 'Art');
Can anyone help by pointing out the probable error in my syntax.
Thanks,
Mark