Jump to content

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


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

}

 

  } ?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.