Jump to content

Archived

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

juanc

a layout issue from a mysql query

Recommended Posts

Hi

I’m trying to display some thumbnail images I have via a mysql query.

The problem I have though is in trying to achieve a certain layout.

I want a row of three individual items then another three underneath and so on. 

basically a replica of this…… http://www.templatemonster.com/category.php?type=0&tid=+-+Any+-&search_words=+-+Any+-&from_=&to=&cat=57&style=0&author=0&x=24&y=8

What I’ve always been used to in the past is outputting one item per row, where as this would be three database rows in one html table row. 

is there possibly abit of code that could put in a line break each time three items are displayed.

while($row = mysql_fetch_array($query))
  {
        // abit of code here to put in a line break after 3 items
      echo row[‘item’];
  }

Or perhaps someone could suggest another way.

Share this post


Link to post
Share on other sites
Have a read of [url=http://www.phpfreaks.com/forums/index.php/topic,95443.0.html]this FAQ thread[/url] it should be able to help.

Share this post


Link to post
Share on other sites
[code]
<?php
  $count = 0;
  while ($row = mysql_fetch_array($query)) {
      if ($count == 3) {
          //do your line break
          $count = 0;
      }       

      echo row['item'];
      $count++;
  }
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.