#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    OK, this is the deal: I have a table in the database which has a picture (a link to the picture, to be

    more precise) and a name of some person. I want to select the names and links to the pics and display

    them in a table.

    And that is not tough.

    What troubles me is this: how do I limit the output to 5 columns on each row??? Something like this:
    <td align="center"><?php echo $rows["image_link"]?><br><?php echo $rows["name"]?></td> and five times

    like that, and then to make a new row and continue.

    I anyone out there knows what I am talking about, please help...I am desperate
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    <?php $y=0;?>
    As below but you will need 2 arrays 1 for the links and 1 for the names then just add in link[$y] & name[$y] in the table.

    <table>
    <?php for($t=0;$t<=3;$t++){ ?>
    <tr>
    <?php for($x=1;$x<=5;$x++){$y++;?>
    <td><?php echo "name $y";?><br><?php echo "link $y";?></tr>
    <? } ?>
    </tr>
    <? }?>
    </table>

    I find it is easier in the end to name the image after the id of the field - ie if john is record no 1 image 1.gif is a picture of john so you can then use the index of the field instead of having an extra field for the image reference ie:

    if $name[$x] is simon the echo "$name[$x].gif" is a picture of me!

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    Of course. A loop inside a loop. And since I will be pulling data from a database, I could use a function to number the rows returned by the SELECT statement, right??

    Thanks a lot!!!!

Similar Threads

  1. PHP and Table Relationship question
    By spank in forum PHP Development
    Replies: 4
    Last Post: February 9th, 2004, 09:24 PM
  2. SSL & PHP together question?
    By asedesigns in forum Apache Development
    Replies: 1
    Last Post: February 7th, 2004, 10:35 PM
  3. UNIQUE Values for a column -newbie question
    By bobby11 in forum MySQL Help
    Replies: 3
    Last Post: February 5th, 2004, 07:31 AM
  4. PHP Mailing list Question
    By byte me in forum PHP Development
    Replies: 3
    Last Post: January 23rd, 2004, 07:55 AM
  5. Php + Flash Question
    By ORANGE900 in forum PHP Development
    Replies: 0
    Last Post: January 23rd, 2004, 02:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo