1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| $sql = 'SELECT * FROM test';
ini_set('mysql.trace_mode', true);
mysql_connect('localhost', 'root', '');
mysql_select_db('test');
mysql_set_charset('utf8');
$result = mysql_query($sql);
if(false !== $result)
{
if(mysql_num_rows($result) > 0)
{
echo '<table border="1">';
$row = mysql_fetch_assoc($result);
echo '<tr><th>', implode('</th><th>', array_keys($row)), '</th></tr>';
do
{
echo '<tr><td>', implode('</td><td>', $row), '</td></tr>';
}
while($row = mysql_fetch_row($result));
echo '</table>';
}
mysql_free_result($result);
} |
Partager