Results 1 to 3 of 3

Thread: How to set table cols and rows

  1. #1
    Join Date
    May 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to set table cols and rows

    I'm trying to make a table of images that I have stored in a database. When it prints out the images they are in a straight line horizontal or vertical, is there a way I can tell the table how many cols I want and the spill over will start a new row?

    Example. I want 3 cols and 3 rows
    Last edited by sinox; 05-24-2007 at 02:35 AM.

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    You can develop an HTML table based on the number of rows and columns you need and that will solve your problem

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    <table>
    <tr><td>1</td><td>2</td><td>3</td></tr>
    <tr><td>4</td><td>5</td><td>6</td></tr>
    <tr><td>7</td><td>8</td><td>9</td></tr>
    </table>

    to output that from a database, simply create a loop.
    for ($i=0;$i<3;$i++) ... that will go every three times,
    then you can create the rest of it.

    So, something like--

    echo "<table><tr>\n";
    foreach ($images as $image) {
    echo "<td><img src=\"$image\" alt=\"image\"></td>";
    $i++;
    if ($i&#37;3 == 0) {echo "</tr><tr>"; }
    }
    echo "</tr></table>";
    Last edited by djr33; 05-24-2007 at 06:19 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •