|
Posted by Martin Mouritzen on 11/01/06 17:39
On Wed, 1 Nov 2006 15:41:42 -0000, "linda" <n0spamF0rme@tiscali.co.uk>
wrote:
>It does remove the null value, but it also removes every thing associated
>with this entry. The name, info, id etc..
Hi Linda,
First of all, your problem is because you don't do anything in the if
statement, you have to have the IF statement where you write out the
amount or assign the value to a variable which you then use when
printing the price.
It also seems like your code is a bit unstructured, I've tab-indented
some of the code.
try to replace your code with the code I've written below and it
should work as you want.
[php]
// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$price = ($row['price']);
print "<tr>";
print "<td align=\"center\" valign=\"middle\">";
print "<a
href=\"image_window.php?id=".$row['id']."\"
onclick=\"window.open(this.href, 'child','height=300,width=431');
return false;\">";
print "<img
src=\"img/".$row['sm_pic']."\" class=\"imageborder\" />";
print "</a>";
print "</td>";
print "<td>";
print "<b>".$row['name']."</b>";
print "<br><br>";
print stripslashes($row['info']);
print "<br><br>";
print "<div class=\"".$row['name']."\">";
if ($price) {
print "£";
print number_format($price,2);
}
print "</div>";
print "<br><br><hr>";
print "</td>";
print "</tr>";
}
mysql_free_result($result); // Free up the resources.
mysql_close(); // Close the database connection.
?>
[/php]
--
best regards,
Martin Mouritzen.
http://www.siteloom.dk
[Back to original message]
|