Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populating a 4x8 table

    I am styling a store script and I need to populate a 4x8 table with this one query that spits out products. Now I don't know how to tell it to do new <tr> after 4 <td> so it would be 4x8 table. Surely someone knows how to do that. Please Help.

  • #2
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    use counters eg:
    PHP Code:
    $rowcount=0;
    while (
    query) {
     if (
    $rowcount==0) {
     echo 
    "<tr><td>";
     echo 
    $dbstuff[];
     echo 
    "</td>";
     
    $rowcount=$rowcount+1;
     }
     if ( (
    $rowcount==2) ||  ($rowcount==3)) {
      echo 
    "<td>";
      echo 
    $dbstuff[];
      echo 
    "</td>";
      
    $rowcount=$rowcount+1;
     }
     if (
    $rowcount==4) {
     echo 
    "<td>";
     echo 
    $dbstuff[];
     echo 
    "</td></td>";
     
    $rowcount=0;
     }

    then put a colcount in there too and an overall if colcount==8 break to finish the display loop.

    there may be an easier way but thats all i could think of off top of head
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com


  •  

    Posting Permissions

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