Maybe you can round the problem with

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

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


-----Original Message-----
From: Frank Miller [mailto:[EMAIL PROTECTED]] 
Sent: 18. helmikuuta 2002 16:05
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
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
calendar if there are no events for that day I want to print a message
the web page saying as much.  I've read the documentaion that said if
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!";
         echo "blah, blah, blah";

The problem is if there are no records that match the select then it
goes to the  else part.  I've tried printing the value of $num and it
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
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

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 (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to