Jump to content

[SOLVED] line break after every 4 records from mysql database


brem13

Recommended Posts

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++;

}

 

  } ?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.