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 Link to comment https://forums.phpfreaks.com/topic/135825-solved-repeating-a-loop/ 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 Link to comment https://forums.phpfreaks.com/topic/135825-solved-repeating-a-loop/#findComment-707965 Share on other sites More sharing options...
Andrew R Posted December 6, 2008 Author Share Posted December 6, 2008 Thanks a million! Link to comment https://forums.phpfreaks.com/topic/135825-solved-repeating-a-loop/#findComment-708001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.