Andrew R Posted December 6, 2008 Share Posted December 6, 2008 I have the following query… $query_news = "SELECT * FROM news"; $news = mysql_query($query_news, $conn_aasv) or die(mysql_error()); $row_news = mysql_fetch_assoc($news); $totalRows_news = mysql_num_rows($news); do { echo $row_news[‘title’]; } while ($row_news = mysql_fetch_assoc($news)); How would I reuse/repeat the above loop so I could use it on different parts of my pages, instead of having to write a new query for every one? Would I use mysql_data_seek somewhere in the script above? Thanks Quote Link to comment Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 yes mysql_data_seek($news, 0); $row_news = mysql_fetch_assoc($news);//starts again Quote Link to comment Share on other sites More sharing options...
Andrew R Posted December 6, 2008 Author Share Posted December 6, 2008 Thanks a million! 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.