how to print data in a table from mysql

Posted by robertdd on Stack Overflow See other posts from Stack Overflow or by robertdd
Published on 2010-03-18T07:25:46Z Indexed on 2010/03/18 7:31 UTC
Read the original article Hit count: 154

Filed under:
|
|
|
|

hello,

i want to extract the last eight entries from my database and print them into a 2 columns table!like this:

|1|2|
|3|4|
|5|6|
|7|8|

is that possible?

this is my code:

$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect(); 

    $sql = "SELECT ID, movieno
            FROM movies
            ORDER BY ID DESC
            LIMIT 8 ";

    $rows = $db->query($sql);

    print '<table width="307" border="0" cellspacing="5" cellpadding="4">';
    while ($record = $db->fetch_array($rows)) {
        $vidaidi = $record['movieno'];
        print <<<END
        <tr>
            <td>
                <a href="http://www.youtube.com/watch?v=$vidaidi" target="_blank">

                <img src="http://img.youtube.com/vi/$vidaidi/1.jpg" width="123" height="80"></a>   
            </td> 
        </tr>
    END;
    }
    print '</table>';  

© Stack Overflow or respective owner

Related posts about php

Related posts about database