#1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    I have a PHP program that first of all, assigns an ID number to an image, then uploads the image into a directory on the server and gives it the ID number as a name (for example, 365912546.gif) and finally adds a database record containing the image ID number and the time the image is added. I then want to have a program that retrieves the images and prints them in an HTML table. But, here's the catch: I want there to be four images on each table row. So, the process that retrieves the images and puts them in a table would run four times, then restart. I've no idea how to do this at all: hopefully someone reading this does! Please help me out if you can.

    --------------------------------------------
    Alex
    (http://www.alex-greg.co.uk)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    Do you mean that there would be four cells to each row across? This is how I do it and it wprks great
    //Set this to be the number you want across
    $rows = 4;
    $i = 1;
    print '<table><tr>';
    while ($row = mysql_fetch_array($result)) {
    if (is_int($i / $rows)) {
    print '<td><img src="'. $row["imagefield"] .'"></td></tr><tr>';
    }
    else {
    print '<td><img src="'. $row["imagefield"] .'"></td>';
    }
    }
    print '</tr></table>';

Similar Threads

  1. Query for Retrieving Results on a Quartely basis
    By srinig2002 in forum Database Management
    Replies: 1
    Last Post: February 6th, 2004, 04:39 PM
  2. (mysql) retrieving 1 row instead of 40 rows
    By ol4pr0 in forum PHP Development
    Replies: 8
    Last Post: January 30th, 2004, 04:22 PM
  3. limit mysql display results into 3 table rows
    By bcounsell in forum MySQL Help
    Replies: 1
    Last Post: January 9th, 2004, 08:16 AM
  4. Limit results on 'left join' query
    By tippiedog in forum MySQL Help
    Replies: 1
    Last Post: November 12th, 2003, 08:58 AM
  5. Query Results and affected rows?
    By MrSlappyPants in forum PHP Development
    Replies: 2
    Last Post: October 24th, 2003, 10:04 PM

IMN logo majestic logo threadwatch logo seochat tools logo