Re: HALP I've fallen and I can't get up

From: Date: Sun, 11 Jun 2000 01:48:07 +0000
Subject: Re: HALP I've fallen and I can't get up
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-310@lists.php.net to get a copy of this message
Hi, Take a look at what mysql_query() returns. It's a mysql result id, not an array. You'll need to use the other mysql_* functions to make use of it. ie. $result = mysql_query('select name,address from people'); print "there are ".mysql_num_rows($result)." people in the database<br><br>\n"; while(list($name, $address) = mysql_fetch_row($result)) print "$name lives at $address<br>\n"; Dan Ellis wrote: > > Having an issue here with returning a count of entries in a database. $result. The count that > $result returns is 2 so that if I use a for loop to generate the query times "see for > loop" all I get is 2 records returned.... what I am trying quite poorly to do is use a for loop > incrementing from the count of results in a database so that if there are 40 records or 1 record > that is returned and the count is generated from there. > > Please see example. > > <? > $Daze = Date("m-Y") ; > > $hostname = "*********"; > $username = "*****"; > $password = "****"; > $dbName = "****"; > $userstable = "*******"; > > $mysql_link = MYSQL_CONNECT($hostname,$username,$password); > > @mysql_select_db("$dbName"); > > $query = "SELECT * FROM herb_news"; > > $result = MYSQL_QUERY($query); > > for($i = 0; $i <= count($result)+1; $i ++){ > > $news_month = mysql_result($result,$i,"news_date"); > $title = mysql_result($result,$i,"news_title"); > $news_body = mysql_result($result,$i,"news_article"); > > if ($news_month == "$Daze"){ > print "<p align=\"left\"><font size=4 > ><b>$title</b></font></p><p > align=\"left\">$news_body</p>"; > } > > } > > ?> > > halp please > > Dan Ellis

« previous php.db (#310) next »