rofl90 Posted February 20, 2008 Share Posted February 20, 2008 Heres my code <?php $host = 'xx'; $user = 'xx'; $pass = 'xx'; $db = 'xx'; mysql_connect($host, $user, $pass) or die(mysql_error()); mysql_select_db($db); $info = mysql_query("SELECT * FROM support;"); $i = mysql_fetch_object($info); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Email</th> <th>Reason</th> <th>Message</th> </tr>"; // keeps getting the next row until there are no more to get // Print out the contents of each row into a table echo "<tr><td>"; echo $i->name; echo "</td><td>"; echo $i->email; echo "</td><td>"; echo $i->reason; echo "</td><td>"; echo $i->message; echo "</td></tr>"; } echo "</table>"; mysql_close() ?> Link to comment https://forums.phpfreaks.com/topic/92037-displaying-only-one-record/ Share on other sites More sharing options...
cyrixware Posted February 20, 2008 Share Posted February 20, 2008 $info = mysql_query("SELECT * FROM support"); or ex.. $SearchResult=mysql_query("SELECT * FROM support ORDER BY yourfield") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/92037-displaying-only-one-record/#findComment-471362 Share on other sites More sharing options...
akitchin Posted February 20, 2008 Share Posted February 20, 2008 the issue is that you must loop through the results: while ($i = mysql_fetch_object($info)) { // row echoing stuff here } the resource returns a resultset that requires a loop to go through. when you only use one call of mysql_fetch_object(), it'll just grab the row the resultset is pointing to. Link to comment https://forums.phpfreaks.com/topic/92037-displaying-only-one-record/#findComment-471369 Share on other sites More sharing options...
rofl90 Posted February 20, 2008 Author Share Posted February 20, 2008 got it just a second ago, thx anyway )) Link to comment https://forums.phpfreaks.com/topic/92037-displaying-only-one-record/#findComment-471373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.