Re: while loop with if statement - here's the code
| From: | Steve Brett | Date: | Mon, 20 Aug 2001 15:24:25 +0000 |
| Subject: | Re: while loop with if statement - here's the code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63523@lists.php.net to get a copy of this message | ||
try using mysql_num_rows() to get the number of rows returned by the query.
you need to supply it with the identifier for the query not the sql you sent
to the query. not exactly sure what you're trying to do though ...
Steve
<sgibbs@vt.globalhealth.org> wrote in message
news:BB6D932A42D6D211B4AC0090274EBB1D2EF0F0@GLOBAL1...
> Thanks Steve! :) Here's the code:
>
> <?
>
> $results = mysql_db_query("$db", "select * from $table where $query order
> by update_datetime desc limit $offset, 10");
>
> while($one = mysql_fetch_array($results)){
> $id=$one["id"];
> $title=$one["title"];
> $description=$one["description"];
>
> print "
> <TR><TD VALIGN=TOP><img src=/assets/images/bullet.gif width=10
> height=8></TD><TD><FONT FACE=VERDANA,ARIAL,HELVETICA,SANS-SERIF
> SIZE=2><A
> HREF=/view_top.php3?id=$id>$title</A><BR>$description</TD></TR>\n
> <TR><TD VALIGN=TOP COLSPAN=2><img src=/assets/images/spacer.gif
> width=10 height=6></TD></TR>\n
> ";
> };
>>>>>>>>>>>>>>>$numrows=mysql_num_rows($one);
> if($numrows= =0)
> {
> print "
> <TR><TD><FONT FACE=VERDANA,ARIAL,HELVETICA,SANS-SERIF SIZE=2>NO
> RESULTS</TD></TR>\n
> <TR><TD VALIGN=TOP COLSPAN=2><img src=/assets/images/spacer.gif
> width=10 height=6></TD></TR>\n
> ";
>
> }
>
> ?>
>