Results 1 to 2 of 2

Thread: using While to create rows

  1. #1
    Join Date
    May 2012
    Location
    Wales UK
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default using While to create rows

    Using a table i am to pull out data from my MySQL data-base, generaly works fine but what i need to do is pull the data out then go on to a new column of the same row but want it to go 3 columns then make a new row, so pull data out tell it has 3 columns with data then go to a new row then do another 3 columns filled out. The current one does 1 column then does a new row so how would i go about doing 3 columns then going to a new row after it has 3? Thanks in advance this is my current set up
    PHP Code:
    <?php
                   
    while ($row mysql_fetch_array($query)) {
                       echo 
    "<tr>";
                       echo 
    "<td>".$row["thedate"]."</td>";
                       echo 
    "</tr>";
                   }

                
    ?>

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    This is the method that I use
    PHP Code:
    $column 3;
    $rowend 1;
    echo 
    '<table><tr>';
    //Run your loop here

    while ($row mysql_fetch_array($query)) {
                       echo 
    "<td>".$row["thedate"]."</td>";

    if (
    $rowend == $column){ echo "</tr><tr>"$rowend=0;}
    $rowend++;
    }
    echo 
    '</tr></table>'

Similar Threads

  1. how to get rows??
    By php_techy in forum MySQL and other databases
    Replies: 1
    Last Post: 06-13-2010, 08:20 PM
  2. Create html page that lets user create their own document
    By kc104 in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-28-2009, 10:05 AM
  3. sorting rows
    By boogyman in forum PHP
    Replies: 0
    Last Post: 08-27-2007, 09:44 PM
  4. count rows and then use them
    By Dennis_Gull in forum PHP
    Replies: 2
    Last Post: 05-01-2007, 08:10 PM
  5. Replies: 10
    Last Post: 08-05-2005, 12:39 PM

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
  •