Canman2005 Posted October 19, 2008 Share Posted October 19, 2008 Hi all I have a very simple QUERY, looks like <?php $sql = "SELECT * FROM `users` WHERE `area` = '99'"; $show = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($show)) { print $row['fullname']; print "<br>"; } ?> This returns a list like David Harry Sarah Richard Shelly Bob Jerry Vicki Shaun How is it possible to insert the word "NEXT" after every 4th row returned, so the above output would look like David Harry Sarah Richard NEXT Shelly Bob Jerry Vicki NEXT Shaun Any help would be great Thanks Ed Link to comment https://forums.phpfreaks.com/topic/129030-solved-printing-word-every-4th-row-returned/ Share on other sites More sharing options...
ghostdog74 Posted October 19, 2008 Share Posted October 19, 2008 you can use a counter while () { $count++; if ( $count == 4 ){ echo "Next\n"; $count=0 } ..... .... } Link to comment https://forums.phpfreaks.com/topic/129030-solved-printing-word-every-4th-row-returned/#findComment-668906 Share on other sites More sharing options...
Canman2005 Posted October 19, 2008 Author Share Posted October 19, 2008 Cool, thanks man Link to comment https://forums.phpfreaks.com/topic/129030-solved-printing-word-every-4th-row-returned/#findComment-668907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.