I'm not surprised
first off I'd layout your code to make it easier on the eye
PHP Code:
<?
$sql = "select * from birds_sighting";
$result = mysql_query ($sql);
if ($row="1")
{ $field4= $row["bait_type"];
echo "<img src='bait1.gif'>";
}
?>
<?
$sql = "select * from birds_sighting";
$result = mysql_query ($sql);
while ($row = mysql_fetch_array($result))
{ $field3= $row["bait_amount"];
echo "$field3<br>";
}
?>
personally I like to layout code as above as I find it easier to idenify missing brackets, however semingly the standard/semi official approach is
PHP Code:
if ($row="1") {
$field4= $row["bait_type"];
echo "<img src='bait1.gif'>";
}
first off you don't assign a value to the variable $row in the first if block, its as if the if has no relation to the sql statement above.
you don't need to assign the value from the $row if you are doing no further processing on it
ie
PHP Code:
while ($row = mysql_fetch_array($result))
{ $field3= $row["bait_amount"];
echo "$field3<br>";
}
instead can be rewritten as
PHP Code:
while ($row = mysql_fetch_array($result))
{ echo $row["bait_amount"]."<br>";
}
incidentally you will help yourself by by giving your script variable more understandable names eg instead of field3 call t, say BaitAmount. the problem is not whilst writing the script, its when you come to revisit the script in 2..3 weeks, months or years