Re: COUNT(*)

From: Date: Fri, 01 Aug 2003 08:39:28 +0000
Subject: Re: COUNT(*)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-157907@lists.php.net to get a copy of this message
Actually that does retrieve the number of rows.. // Query $query = "SELECT COUNT(*) AS count FROM pet"; // Execute Query $result = mysql_query($query); // Get the result of query named count $count = mysql_result($result,0); echo $count." is the number of rows"; Cheers! Rick In order to seek truth it is necessary once in the course of our life to doubt as far as possible all things. - Rene Descartes > From: Yury B. <www@body-builders.org> > Reply-To: www@body-builders.org > Date: Thu, 31 Jul 2003 19:46:40 +0200 > To: php-general@lists.php.net > Subject: [PHP] COUNT(*) > > Hi > > I used to use old fashioned mysql quieries but moderm mysql > apparently became more flexible so. I want to understand how to use > some of the new features like COUNT(*) > > Let's say I have > $result="SELECT COUNT(*) FROM pet"; > $sql=mysql_query($result); > while ($row=mysql_fetch_array($sql)){ > $pet_name=$row['pet_name']; > echo ......; > } > > the question is how do I actually retrieve the number of rows of sql > query result? > > Yury > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#157907) next »