benji87 Posted November 29, 2006 Share Posted November 29, 2006 I know im probably being dumb here but what is the correct syntax to use in a query when you want to return more than one result that has the same data in a field of the database??for example:[code] SELECT * FROM table WHERE topicid = $id [/code]I cant only get it to return to me one result otherwise i get a syntax error.Basicly its for a comments page it will show all the comments made on a topic contained in another table.It seems to be finding only one match at the moment and not all of them! Quote Link to comment Share on other sites More sharing options...
alpine Posted November 29, 2006 Share Posted November 29, 2006 Your syntax is correct, but put it in a while loop:[code]<?php$select = mysql_query("select * from table where topicid = $id") or die(mysql_error());while($row = mysql_fetch_array($select)){ echo "<p>".$row['comment']."</p>";}?>[/code] 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.