<?php
header('content-type:text/html; charset=utf-8');
$mysql_server_name="localhost"; //˽¾ݿ⸾ϱǷĻ³č
$mysql_username="root"; // l½Ԋ�û§Ļ
$mysql_password="123456"; // l½Ԋ�݂鋊 $mysql_database="product"; // ˽¾ݿⶄĻؖ
// l½ӵ½˽¾ݿˊ $conn=mysql_connect($mysql_server_name, $mysql_username,$mysql_password) or die('Can not connect to MYSQL SERVER !');
mysql_select_db($mysql_database) or die('DB not exists !');
mysql_query("set names 'utf8'");
// ´ӱ͡ȡхϢµóqlԯ¾⋊ $strsql="select * from company";
// ִѐsql²ꑯ
$result=mysql_query($strsql);
// »ꑯ½ẻ
$row=mysql_fetch_row($result);
echo '<font face="verdana">';
echo '<table border="1" cellpadding="1" cellspacing="2">';
// Дʾؖ¶σ� echo "\n<tr>\n";
for ($i=0; $i<mysql_num_fields($result); $i++)
{
echo '<td bgcolor="#000F00"><b>'.
mysql_field_name($result, $i);
echo "</b></td>\n";
}
echo "</tr>\n";
// ¶¨λµ½µے»͵¼Ȃ¼
mysql_data_seek($result, 0);
// ѭ»·ȡ³�¼
while ($row=mysql_fetch_row($result))
{
echo "<tr>\n";
for ($i=0; $i<mysql_num_fields($result); $i++ )
{
echo '<td bgcolor="#00FF00">';
echo "$row[$i]";
echo '</td>';
}
echo "</tr>\n";
}
echo "</table>\n";
echo "</font>";
// ˍ·Ɨ˔´
mysql_free_result($result);
// ¹رց¬½э
mysql_close();
?>