<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的文章呢?

解决方案 »

  1.   

    $_GET["id"]试试这个值表面上看不出$_GET[fl]这个值存在
      

  2.   

    既然是 http://localhost/wosheji/lantan/fl.php?id=java
    那么就 、$arr=mysql_query("select fl from luntan where fl=$_GET[id] ",$conn);
      

  3.   

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\wosheji\lantan\fl.php on line 23
     2楼的哥哥 出现这样的错误
      

  4.   

    $id = empty($_GET['id']) ?  'xxx' :$_GET['id'] ;
    $arr=mysql_query("select fl from luntan where fl='{$id}' ",$conn) or die("mysqle error message : " . mysql_error() );
    如果出错了,它将会告诉你什么错误,不明白就把错误信息贴上来
      

  5.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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> 是这个
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <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>
      

  7.   

    就是说喽
     <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>
      

  8.   

    我想我没说清楚。没查询到匹配的结果,这并不是一个错误。
    你确定你的数据库的 luntan表里有 fl列的值为 java 的吗?
      

  9.   

    http://localhost/wosheji/lantan/fl.php?id= java
    你是否是这么访问的,注意id= java这儿有个空格,所以mysql没有找到 fl = ' java' 的列
      

  10.   

    还有,你的SQL语句select fl from luntan ...  只能取得 fl列的值,而你代码中需要的 zuozhe, fs列的值都不会有。 把fl改成 * , 这样子才可以获取到所有列的值。
    $arr=mysql_query("select * from luntan where fl = '{$id}' ",$conn)
      

  11.   

    这种错误八成是sql的问题,可以打印一下sql"select fl from luntan where fl=$_GET[fl] "。然后到msyql执行一下,看看结果。问题一目了然