Reply to Re: not displaying null data when using number_format

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация