<?php
$link = mysql_connect('localhost', 'root', '123456')
or die('Could not connect: ' . mysql_error());
mysql_select_db('ruida') or die('Could not select database');
// 执行 SQL 查询
$query = 'SELECT * FROM product';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// 用 HTML 显示结果
echo "<table>/n";
while ($line = mysql_fetch_assoc($result)) {
echo "/t<tr>/n";
foreach ($line as $col_value) {
echo "/t/t<td>$col_value</td>/n";
}
echo "/t</tr>/n";
}
echo "</table>/n";
// 释放结果集
mysql_free_result($result);
// 关闭连接
mysql_close($link);
?>