Re: more results (loop)

From: Date: Fri, 11 Apr 2003 14:43:39 +0000
Subject: Re: more results (loop)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143510@lists.php.net to get a copy of this message
> I've seem to have forgotten how to do a loop. > how do i get more results when the echo is not in the while loop? > only getting 1 now... > > $result = @mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 3"); > while($row = mysql_fetch_row($result2)) { > $title = $row[2]; > $text = $row[3]; If you want to save these values for use later, you'll need to put them into an array. $title[] = $row[2]; $text[] = $row[3]; > } > > // other queries.... > > echo "$title <br/> $text"; echo $title[0] . '<br>'. $text[0]; where 0 is for the first row returned. As for the other people saying to use mysql_fetch_array instead of mysql_fetch_row, that does not make a difference at all. ---John Holmes...

« previous php.general (#143510) next »