Re: displaying more than one result

From: Date: Fri, 16 Feb 2001 20:09:24 +0000
Subject: Re: displaying more than one result
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40213@lists.php.net to get a copy of this message
Matt Davis pressed the little lettered thingies in this order... > I have a php script which runs a query and then outputs the results in to > html. The html should repeat itself depending on the number of results. i.e > to produce search results. > > I know that my current query should return 5 results however it is only > show the last one. Is there something I need to do to show all my results. > It sounds like you're ending your loop too soon. Something like: $result=mysql("DB","query"); while ($row = mysql_fetch_row($result)) { $var = $row[0]; } echo $var; This causes the while() loop to perform and on each loop (each result), the value of $var gets replaced with the next value. When you do this and you cause the loop to exit, you will only see the last value of $var (the last result from the query). Try placing the "echo $var;" portion within the curly braces. This will cause the value of $var to be echoed for each result. If I'm wrong, you'll need to send the code you are trying to use for anyone to be of much help. Good luck... Christopher Ostmo a.k.a. tech@AppIdeas.com AppIdeas.com For a good time, http://www.AppIdeas.com/

« previous php.general (#40213) next »