You are here: Re: PHP help with if else « All PHP « IT news, forums, messages
Re: PHP help with if else

Posted by Tom on 08/28/07 17:19

On Mon, 27 Aug 2007 12:22:07 -0400, Steve wrote...
>
>Can anyone help me with this code. What I want to do is check the DB and if
>there is no result returned (by checking the date field) I want to echo "no
>shows".
>
>But no matter what I do it seems to blow through ANY if else statements I try
>and if there are dates it shows them if not it is just blank.
>
>is it as simple as my code being screwed up or am i missing something else?
>
>Steve
>
>
>while($band = mysql_fetch_array($result, MYSQL_ASSOC))
>{
>
>$change_to_time = strtotime($band[date]);
>$newdate = date('m.d.Y', $change_to_time);
>
>
>if (empty($band[date])) {
>echo "No shows on the calendar.";
>}
>
>else {
>echo "<div id=\"line1\">$newdate - $band[venue]</div>";
>echo "<div id=\"line2\">$band[street] $band[city], $band[state] - <a href =
>\"http://maps.google.com/maps?q=$band[street]+$band[city]+$band[state]\">Map</
>a></div>";
>echo "<div id=\"line3\">$band[notes]</div>";
>echo "<div id=\"line4\">Time - $band[time], Cost - $band[cost]</div>";
>echo "<hr />";
>}
>
>}
>
>


If you're using a SELECT statement, I think the "mysql_num_rows()" function is
what you're looking for...


<?
$num_rows = mysql_num_rows($result);

if($num_rows >= 0)
{
//get results

)
else
{
//no results
echo "No shows on the calendar.";
}
?>


Tom
--
NewsGuy Takes Usenet Cellular!
Download newsgroup MP3's to your Cell or PDA
Free Trial - http://newsguy.com/cellphone.htm

 

Navigation:

[Reply to this 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

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