I have a script that passes a drop-down selection to a results page which grabs the information for the town selected in the drop down menu. I have an error in my fetch array though?
CAN ANYBODY HELP A BROTHER OUT?
Anywhoo. here is the first page:
$result = mysql_query("SELECT * FROM funeralhomes ORDER BY city ASC",$db);
while ($myrow = mysql_fetch_assoc($result))
{
$name = $myrow["name"];
$id = $myrow["id"];
$city = $myrow["city"];
$address = $myrow["address"];
$state = $myrow["state"];
$zip = $myrow["zip"];
$phone = $myrow["phone"];
$fax = $myrow["fax"];
$email = $myrow["email"];
echo "<option value=$city >$city ,$state ($name)";
}
echo "</select>";
echo "<p>";
echo "<center>";
?>
<input type="submit" name="view" value="View Info" />
</form>
And here is the proccessing part:
//// display individual record
if ($id) {
$result = mysql_query("SELECT * FROM funeralhomes WHERE city=$city",$db);
$myrow = mysql_fetch_array($result);
$name = $myrow["name"];
$address = $myrow["address"];
$city = $myrow["city"];
$state = $myrow["state"];
$zip = $myrow["zip"];
$phone = $myrow["phone"];
$fax = $myrow["fax"];
$email = $myrow["email"];
?>
<table width="35%" border="0" cellspacing="0" cellpadding="0" align=center>
<tr>
<td width="25%"> </td>
<td width="75%"><font size="4" color="blue"><b><font color="blue"><?php echo $name; ?></font></b></font>
</td>
</tr>
<tr>
<td width="25%"><b><font size="3"></font></b></td>
<td width="75%"><b><font size="3"><?php echo $address; ?></font></b></td>
</tr>
<tr>
<td width="25%"><b><font size="3"></font></b></td>
<td width="75%"><b><font size="3"><?php echo "$city, $state $zip"; ?></font></b></td>
</tr>
<tr>
<td width="25%"><b><font size="3"></font></b></td>
<td width="75%"><b><font size="3"></font></b></td>
</tr>
<tr>
<td width="25%"><b><font size="3"></font></b></td>
<td width="75%"><b><font size="3"><?php echo $phone; ?></font></b></td>
</tr>
<tr>
<td width="25%"><b><font size="3"></font></b></td>
<td width="75%"><b><font size="3"><?php echo $fax; ?></font></b></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="75%"> </td>
</tr>
<tr>
<td width="25%">
<div align="right"><a href=\"mailto:$email\"><img src=images/icon_email.gif border=0></a> </div>
</td>
<td width="75%"><font color="green"><b><font size="3"><?php echo $email; ?>
</font></b></font></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="75%"> </td>
</tr>
<tr>
<td width="25%" height="25"> </td>
<td width="75%" height="25"><b><font color="blue"><a href=newspapers_view.php>Click Here To Go Back</a></font></b></td>
</tr>
</table>
<?php
} else {
// show employee list
$result = mysql_query("SELECT * FROM funeralhomes ORDER BY id DESC",$db);
// begin to show results set
$count = 1 + $s ;
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
$title = $row["firm"];
// ****************TEST EDITS***************
$name = $row["name"];
$address = $row["address"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];
$phone = $row["phone"];
$fax = $row["fax"];
$email = $row["email"];
echo "<tr><td><i><font size=2>Result $count:</font></i></td></tr>
<tr><td><b><font color=blue size=3>$title</font></b></td></tr>
<tr><td><font size=2>$address</font></td></tr>
<tr><td><font size=2>$city, $state $zip</font></td></tr>
<tr><td><font size=2>$phone</font></td></tr>
<tr><td><font size=2>$fax (f)</font></td></tr>
<tr><td><font size=3 color=green><b>$contact</b> <a href=\"mailto:$email\"><img src=images/icon_email.gif border=0></a></font></td></tr><tr><td> </font></td></tr>
<p>";
$count++ ;
}
}
?>
</table>
</html>
I am getting the error on line 18 saying that
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/scfdaorg/wwwroot/scfda.org/member/funeralhome_view_results.php on line 18
Thanks for trying to help this problem.
CMPENNIGNTON