ROW n COLUMN

Discussion in 'PHP' started by badmasketa, Mar 14, 2008.

  1. #1
    i need help here
    i want to display the data of mysql table in row and column wise. can you guys help me out.

    i wanna show in 3 column X 4 row wise.
     
    badmasketa, Mar 14, 2008 IP
  2. Christian Little

    Christian Little Peon

    Messages:
    1,753
    Likes Received:
    80
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This will display a 3 column table and show every row in the database table in case you expand it down the road. Change colname1, colname2, and colname3 to whatever the columns are named in your mysql table.

    
    
    $query = "select * from tablename";
    $result = mysql_query($query);
    echo "<table>";
    while($row = mysql_fetch_object($result)) {
      echo "<tr><td>" . $row->colname1 . "</td><td>" . $row->colname2 . "</td><td>" . $row->colname3 . "</td></tr>;
    }
    echo "</table>";
    
    
    PHP:
     
    Christian Little, Mar 14, 2008 IP