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! Link to comment https://forums.phpfreaks.com/topic/28862-quick-query-question/ 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] Link to comment https://forums.phpfreaks.com/topic/28862-quick-query-question/#findComment-132121 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.