Re: $result = mysql_query($query);

From: Date: Sat, 14 Sep 2002 19:42:55 +0000
Subject: Re: $result = mysql_query($query);
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116397@lists.php.net to get a copy of this message
I read on php.net that you have to use SELECT count(*) with if(mysql_num_rows($result) != 0) but if i use count(*) and i have no result to show the tile is printed with empty result so i'll use if($row = mysql_fetch_array($result)), work fine, ----- Original Message ----- From: "John Holmes" <holmes072000@charter.net> To: "'DtM'" <info@protento.com>; <php-general@lists.php.net> Sent: Saturday, September 14, 2002 3:05 PM Subject: RE: [PHP] $result = mysql_query($query); > > $query = "SELECT * from TABLE WHERE CHAMP = 'truc' order by NO LIMIT > > 0,10"; > > $result = mysql_query($query); > > > > what i'm trying to do is if the result is !=0 echo the result else > echo > > nothing > > i tried this > > OK, let's think about this. You want to show a result if rows are > returned... > So... > > if($row = mysql_fetch_array($result)) > { > do > { > //do whatever > }while($row = mysql_fetch_array($result)); > } > else > { //no results } > > That'll work fine. Or use mysql_num_rows(), like others suggested. > > ---John Holmes...

« previous php.general (#116397) next »