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

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    15
    http://www.georgiaoffroad.com/test111.php3

    Right now the results print out in a single (long) column. That is functional, but not very pleasing to the eye.

    I'd like to find a way to print 5 <td> cells per table row<tr>, until the query is completed. If 16 entries are found, there would be 4 table rows, with the last having only one entry.

    Am I asking for trouble, or is this doable?

    Current php code for above example:

    while ($myrow = mysql_fetch_array($result)) {

    echo "<tr>nt<td><p class="bold"><a href="dirtbike.php3?model=";
    printf("%s", $myrow['model']);
    echo "">";
    printf("%s", $myrow['year']);
    echo "&nbsp;";
    printf("%s", $myrow['brand']);
    echo "&nbsp;";
    printf("%s", $myrow['modelletters']);
    printf("%s", $myrow['modelsize']);
    echo "</a></td>n";

    }

    Thanks for your help,
    Mike
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    put the first <TR> outside the while-loop... and add a loop-counter variable inside the loop, using it to add a </TR><TR> after every 5 loops...

    so something like this...

    print "<TR>";
    $loop=0;
    while (....)
    {
    print "<td>..all the prints go here..</td>";
    if (++$loop%5==5)
    print "</tr><tr>";
    }
    print "</tr>";


    hope I helped
    //ryan

    [This message has been edited by snoop logy dogg (edited August 29, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    15
    That's sort of what I thought would have to be done.

    Out of curiosity, what is the '%5' sign for in your loop example?

    Thanks,
    Mike
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    15
    It looks like the % sign may have been a keystroke error.

    When I remove it the loop works great.

    Thanks for your help!

    - Mike
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2000
    Posts
    669
    Rep Power
    15
    That is the modulus function, I like to use if (is_int($loop/5)) {

Similar Threads

  1. Replies: 3
    Last Post: February 12th, 2004, 11:04 PM
  2. Replies: 3
    Last Post: February 11th, 2004, 08:30 AM
  3. Will table size affect data retrival time?
    By abones in forum Oracle Development
    Replies: 1
    Last Post: February 10th, 2004, 08:55 AM
  4. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM
  5. How to Extract data from html table?
    By zlozi in forum PHP Development
    Replies: 4
    Last Post: January 17th, 2004, 07:43 AM

IMN logo majestic logo threadwatch logo seochat tools logo