求助:如何编写php代码来查询mysql里的数据

求助:如何编写php代码来查询mysql里的数据

求助:如何编写php代码来查询mysql里的数据~!
在此先感谢了啊~!

建议去买本书.先学好基础.自然就明白了

[复制到剪切板]
CODE:
<?php 
$conn 
mysql_connect("localhost","root","");
mysql_query("set names 'gbk'");//这就是指定数据库字符集,一般放在连接数据库后面就系了
mysql_select_db("test");

$sql "select * from mysqlcode";
$result mysql_query($sql,$conn);

?>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<
title>mysql 字符编码</title>
</
head>

<
body>
<
table width="300" height="32" border="1" align="center" cellpadding="0" cellspacing="0"
  <
tr>
    <
td width="71" align="center">id</td>
    <
td width="229" align="center">内容</td>
  </
tr>
 <?
php while($row mysql_fetch_assoc($result)){
 echo 
"  
 <tr>
    <td align=\"center\">"
.$row['id']."</td>
    <td>"
.$row['content']."</td>
  </tr>"
;
}?>  
</
table>
</
body>
</
html>
<?
php mysql_free_result($result);?> ;

如履薄冰

谢谢老大~!一定听您的建议~!买一本书好好看看~!