brem13 Posted March 4, 2009 Share Posted March 4, 2009 ok, so i have a code on my page that displays 'featured' pictures on my site. it looks through one of my databases and only displays 'featured' pics. and im trying to have it display 4 pictures per row on my page. when i try to make a while loop and put a line break after 4 records it shows 4 of every picture. can somone help me to understand how to have it loop through and put a line break after every 4th picture. any help to understand how to do loops will be appreciated, as this is a part of programming ive always had trouble with. thank you code i have now is below. <h1>Featured Pics</h1> <?php include("../../../configpic.php"); $username1 = basename(dirname(__FILE__)) ; $username2 = strtolower($username1); $featured = "Yes"; mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); $result = mysql_db_query($database, "select * from $username2 WHERE featured = '$featured'") or die (mysql_error()); $folder = "galleries/members/".$username1; while ($qry = mysql_fetch_array($result)) { $c = 1; while($c < 5) { echo '<a href="'.$qry[album].'/'.$qry[picture].'"><img src="'.$qry[album].'/thumbs/'.$qry[picture].'"></a><br />'; $c++; } } ?> Link to comment https://forums.phpfreaks.com/topic/147961-solved-line-break-after-every-4-records-from-mysql-database/ Share on other sites More sharing options...
fenway Posted March 4, 2009 Share Posted March 4, 2009 If you're going to mark a topic "solved", then please post the solution for the benefit of others. Link to comment https://forums.phpfreaks.com/topic/147961-solved-line-break-after-every-4-records-from-mysql-database/#findComment-776673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.