DaveLinger Posted July 15, 2007 Share Posted July 15, 2007 $query="SELECT * FROM reviews WHERE type='frozen' ORDER BY title ASC"; $result = mysql_query($query) or die ("Problem with the query".$query. mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; $rating = $row['rating']; $price = $row['price']; echo " <tr> <td>$title</td> <td>$price</td> <td>$rating</td> <td>"; $rid=$id; $show="int"; include('../rating.php'); echo "</td> </tr> "; } For some reason it only echoes one result, then goes on. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 15, 2007 Share Posted July 15, 2007 Better version and should tell you how many results: After figuring it out i think your issue was your var renaming it caused the to get rewritten each iteration of the while loop <?php $query="SELECT id,title,rating,price FROM reviews WHERE type='frozen' ORDER BY title ASC"; $result = mysql_query($query) or die ("Problem with the query".$query. mysql_error()); if($qcount = mysql_num_rows($result) >0){ echo "Displaying: ".$qcount." Results<br/><table>"; while ($row = mysql_fetch_array($result)) { echo " <tr> <td>$row['title']</td> <td>$row['price']</td> <td>$row['rating']</td> <td>"; $rid=$id; $show="int"; include('../rating.php'); //Don't think you want this here, explain what it is echo "</td></tr>\n"; } echo "</table>"; } else{ echo "No results found"; } ?> untested! Quote Link to comment Share on other sites More sharing options...
DaveLinger Posted July 15, 2007 Author Share Posted July 15, 2007 Ah, your code helped me find the real problem. The include which you supposed shouldn't be there in fact should, it echoes an important number. Problem is, in that included file, it has an sql query and result by the same name, so I simply changed the query and result in the included file to queryr and resultr, and it works. Thanks Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 15, 2007 Share Posted July 15, 2007 if you don't mind can i see your include cause your query structure was orignally pretty poor (not to rag on you) and I like to help you improve this cause this seems like a weak system. select queries are not meant to be part of loops ideally Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.