Table formatting with CSS

Discussion in 'PHP' started by bumbar, Sep 9, 2009.

  1. #1
    Hallo!

    The data come from MySql
    is there a way in which to format the table so that data can be derived by column rather than row?

    For example No problem can be derived as:
    horizontal align
    
    row1 row2 row3 row4 row5
    row6 row7 row8 row9 row10
    
    PHP:
    the outcome above use the following code:
    
    $record_count = 0;  //Keeps count of the records echoed.
    $sql_result = mysql_query ("SELECT notice FROM notice ORDER BY notice_id DESC");
    while ($row=mysql_fetch_row($sql_result))
    {
        //Check to see if it is time to start a new row
        //Note: the first time through when
        //$record_count==0, don't start a new row
        if ($record_count % 5==0 AND $record_count != 0)
        {
            echo '</tr><tr>';
        }
    
        echo '<td valign=top>';
        
        //Echo out the entire record in one table cell:
        for ($i=0; $i< count($row); $i++)
        {
            echo $row[$i];
        }
    
        echo '</td>';
        
        //Indicate another record has been echoed:
        $record_count++;
    }
    
    PHP:
    But I want to go in the data column like this:
    vertical align
    
    row1   row6
    row2   row7
    row3   row8
    row4   row9
    row5   row10
    
    PHP:

    Is there such a possibility with PHP or CSS?

    Thanx!:)
     
    Last edited: Sep 9, 2009
    bumbar, Sep 9, 2009 IP
  2. innovatewebs

    innovatewebs Well-Known Member

    Messages:
    194
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    Hi
    Still this open ?
     
    innovatewebs, Sep 9, 2009 IP
  3. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Using the same code as you've used you could add this to your CSS:

    td { display:block; width:50%; }
    tr { float:left; }
    Code (markup):
    Change the width to a value you want.
     
    wd_2k6, Sep 9, 2009 IP