Re: Mysql_num_rows
| From: | Corey Eiseman | Date: | Mon, 18 Feb 2002 14:34:44 +0000 |
| Subject: | Re: Mysql_num_rows | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85201@lists.php.net to get a copy of this message | ||
Hi Frank,
I'm not exactly sure what's up with this, I've definitely used something
similar before without any problems. However, maybe you can work around it
by switching the logic...
if($num)
echo "blah, blah, blah";
else
echo "There are no events scheduled today!";
Wish I had a better suggestion.. Good luck!
Corey Eiseman
Infinite Orange Incorporated
http://infiniteorange.com/
"Frank Miller" <frank.miller@tamut.edu> wrote in message
news:5.1.0.14.2.20020218075302.034d9008@mailserver.tamut.edu...
> 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
>