<form name="form" method="post" action="">
<table width="60%" border="4" align="center" cellpadding="0" cellspacing="0">
<?php
/*连接数据库*/
$conn=mysql_connect("localhost","root","111");
mysql_select_db("register",$conn);
mysql_query("set names utf8");
$arr=mysql_query("select fl from luntan where fl=$_GET[fl] ",$conn);
/*使用while语句循环mysql_fetch_array()函数返回的数组*/
while($result=mysql_fetch_array($arr)){
?>
<tr bgcolor="#999999">
<td width="7%">作者:</td>
<td width="26%" align="left"><?php echo $result['zuozhe'];?></td>
<td width="19%" align="right">发布时间:</td>
<td width="33%"><?php echo $result['fs'];?></td>
</tr>
<tr>
<td height="139" align="left" >fl:</td>
<td colspan="5" align="left" valign="middle"><?php echo $result['fl'];?></td>
</tr>
<?php
} //结束while循环
?>
</table></form>
我的地址栏上显示http://localhost/wosheji/lantan/fl.php?id= java这个id=java我怎么样才能在网页中输出分类为java的文章呢?
<table width="60%" border="4" align="center" cellpadding="0" cellspacing="0">
<?php
/*连接数据库*/
$conn=mysql_connect("localhost","root","111");
mysql_select_db("register",$conn);
mysql_query("set names utf8");
$arr=mysql_query("select fl from luntan where fl=$_GET[fl] ",$conn);
/*使用while语句循环mysql_fetch_array()函数返回的数组*/
while($result=mysql_fetch_array($arr)){
?>
<tr bgcolor="#999999">
<td width="7%">作者:</td>
<td width="26%" align="left"><?php echo $result['zuozhe'];?></td>
<td width="19%" align="right">发布时间:</td>
<td width="33%"><?php echo $result['fs'];?></td>
</tr>
<tr>
<td height="139" align="left" >fl:</td>
<td colspan="5" align="left" valign="middle"><?php echo $result['fl'];?></td>
</tr>
<?php
} //结束while循环
?>
</table></form>
我的地址栏上显示http://localhost/wosheji/lantan/fl.php?id= java这个id=java我怎么样才能在网页中输出分类为java的文章呢?
那么就 、$arr=mysql_query("select fl from luntan where fl=$_GET[id] ",$conn);
2楼的哥哥 出现这样的错误
$arr=mysql_query("select fl from luntan where fl='{$id}' ",$conn) or die("mysqle error message : " . mysql_error() );
如果出错了,它将会告诉你什么错误,不明白就把错误信息贴上来
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form name="form" method="post" action="">
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
</form>
</body>
</html> 是这个
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form name="form" method="post" action="">
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
</table>
</form>
</body>
</html>
<form name="form" method="post" action="">
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
这里本应该是查询的结果,但因为结果为空, mysql_fetch_array($arr)返回false。
自然就不会执行while($result=mysql_fetch_array($arr))循环来输出
</table>
</form>
你确定你的数据库的 luntan表里有 fl列的值为 java 的吗?
你是否是这么访问的,注意id= java这儿有个空格,所以mysql没有找到 fl = ' java' 的列
$arr=mysql_query("select * from luntan where fl = '{$id}' ",$conn)