21,887
社区成员
发帖
与我相关
我的任务
分享
define('DB_host', "localhost");
define('DB_user', "root");
define('DB_password',"root");
define('DB_name',"nav_database");
$db = mysql_connect(DB_host,DB_user,DB_password);
mysql_query("SET NAMES 'gb2312'");
if(!$db){
die("数据库连接失败!");
exit($db);
}
mysql_select_db("DB_name",$db);
<?php
$result=mysql_query("SELECT * FROM url_content");
while($rows=mysql_fetch_array($result))
{
?>
<tr>
<td><?php $rows[name];?></td>
<td><?php $rows[title];?></td>
</tr>
<?php
}
?>
<?php
$db = mysql_connect("localhost","root","root") or die("数据库连接失败" .mysql_error());//数据库连接这么写,你那么写好麻烦
mysql_query("set names gbk");
mysql_select_db("DB_name",$db);
$result = mysql_query("select * from url_content",$db);
while($row=mysql_fetch_row($result)){
?>
<table width="900" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td>name</td>
<td>title</td>
</tr>
<tr>
<td width="300"><?php echo $row[0]?></td>
<td width="300"><?php echo $row[1]?></td>
</tr>
</table>
<?php
}
?>
$result=mysql_query("SELECT * FROM url_content");
$rows=mysql_fetch_array($result);
mysql_select_db("DB_name",$db);
//也许是这里
改为mysql_select_db(DB_name,$db);
$result=mysql_query("SELECT * FROM url_content");
$rows=mysql_fetch_array($result);
print_r($rows);exit;
<?php
$result=mysql_query("SELECT * FROM url_content");
while($rows=mysql_fetch_array($result))
{
?>
<tr>
<td><?php echo $rows[name];?></td>
<td><?php echo $rows[title];?></td>
</tr>
<?php
}
?>