Please show your exact code, because your code snippet looks right.

Then, again, maybe it's because it's an Aggie machine...<GRIN>

-----Original Message-----
From: Niklas Lampén [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 8:11 AM
To: Php-General
Subject: RE: [PHP] Mysql_num_rows


Maybe you can round the problem with

if ($num < 1)
        echo "Nothing today!";
else
        echo "Something to do today!";

if (!isset($num) || $num == 0)...


Niklas


-----Original Message-----
From: Frank Miller [mailto:[EMAIL PROTECTED]] 
Sent: 18. helmikuuta 2002 16:05
To: [EMAIL PROTECTED]
Subject: [PHP] Mysql_num_rows


Thanks to everyone that helped me with my last problem I've run into 
another problem and was wondering if someone here could offer any help
or 
suggestions.  The project I'm working on is an event calender. It does 
several things but the problem I've run into is when I click a date on
the 
calendar if there are no events for that day I want to print a message
on 
the web page saying as much.  I've read the documentaion that said if
I'm 
using a select statement to use mysql_num_rows and that it returns an 
integer. Here is a snippet of my code

$query = "SELECT *,TIME_FORMAT(eventtime, '%l:%i %p')AS eventtime, 
DATE_FORMAT(dateofevent,'%M %e, %Y') AS fdateofevent  FROM tamutevents 
where refid=$refid";

$result = mysql_query($query,$connection) or die("Error in Query"); $num
= mysql_num_rows($result);


Next I say  if ($num == 0)
{
      echo " There are no events scheduled today!";
}
else
     {
         echo "blah, blah, blah";
}

The problem is if there are no records that match the select then it
always 
goes to the  else part.  I've tried printing the value of $num and it
works 
if there is something scheduled but when there is nothing scheduled $num

shows nothing on the screen.

I'm using Mysql 3.23.38 and php 4.06 on a windows test machine but it
works 
the same on php 4.06 and Mysql 3.23.46 on my Linux server.

Has anyone else run into this and if so can you tell me what to do about
it.

Thanks in advance - Frank


Frank Miller
Computer Specialist and Webmaster
Technology and Distance Education
Texas A&M University-Texarkana
2600 North Robison Rd
Texarkana, Texas 75501

Phone:  903-223-3156
Fax:      903-223-3139
Office:   165


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to