busby Posted January 9, 2011 Share Posted January 9, 2011 here is some simple code for getting and displaying fata from a database $sql="SELECT * FROM messages WHERE m_id = '".$id."'"; $result = mysql_query($sql); <table border='0' cellspacing="4"> while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<th>Message</th>"; echo "</tr>"; echo "<tr>"; echo "<td>" . $row['message'] . "</td>"; echo "</tr>"; } now ive used that while loop to display those results how can i do that again without having a new SQL statement. i cant do 2 while loops because the first one has already got to the end of the amount of rows basically how can i have another while loop displaying those same results again? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 9, 2011 Share Posted January 9, 2011 you can. one way is to use mysql_data_seek to set the result pointer back to the first result: } // end first loop mysql_data_seek($result,0); while ($data = mysql_fetch_array($result)) { // start second loop Quote Link to comment Share on other sites More sharing options...
busby Posted January 9, 2011 Author Share Posted January 9, 2011 excellent! thankyou exactly what i was looking for and such a simple solution. 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.