����ķ���չʾ��������ӡ�ִ��һ����ѯ����ӡ�������Ͽ� MySQL ���ݿ�����ӡ�
Example #1 MySQL ��չ��������
<?php
// ���ӡ�ѡ�����ݿ�
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');
// ִ�� SQL ��ѯ
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// �� HTML ��ӡ��ѯ���
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
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);
?>