hi im having trouble accessing using mysql_fetch_assoc i have the following form that presents a drop down menu after querying a database
$query = "SELECT *
FROM COID order by FName";
$result = mysql_query($query);
$number = mysql_numrows($result);
print "Please select a company:<p>
<form action=\"employ.php\" method=\"post\">
<select name=\"Code\">
<option value=\"\">Select a company</option>";
for ($i=0; $i<$number; $i++) {
$Code = mysql_result($result,$i, "Code");
$FName = mysql_result($result,$i, "FName");
print "<option value=\"$Code\">$FName</option>";
}
print "</select><input type=\"submit\" value=\"Select\"
name=\"Company\"></form>";
i then want it to pass the $code to another form which will then query another table and display the results but it doesnt seem to be passing the $code to the next page, its worked in the past i just can see what im doing wrong, i get the following error mysql_fetch_assoc(): supplied argument is not a valid MySQL result
the code below is the second page, many thanks for your help.
<?
$hostname = "localhost";
$username = "pirccgs";
$password = "incomes1";
$dbname= "COMPS";
mysql_connect($hostname, $username, $password);
mysql_select_db($dbname) or die( "cant connect to $dbname");
$query1 = "select COID.FName from COID where COID.Code=$Code";
$result1 = mysql_query($query1);
$row1 = mysql_fetch_assoc($result1);
echo "<form method = \"post\" action=\"employsub1.php\">\n";
echo "<input type = \"hidden\" name = \"Code\" value = \"$Code\">";
?>
<table Width=70% border>
<tr>
<td colspan=4><H3><? echo ("$row1[FName]");?></h3></td></tr>
</html>