<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis">
<title>test</title>
</head><body>
 <a href="show.php"?id=2004>link
 </a>
</body>
</html>

解决方案 »

  1.   

    从数据库中取出id赋值给变量,假设为$id<body>
     <a href="show.php?id="<?=$id?>>link
     </a>
    </body>
      

  2.   

    <?php
    //数据库连接省略....
    $id=10;
    $query="select * from info where id='$id'";
    $result=mysql_query($query);
    while ($row=mysql_fetch_array($result))
    {
    print_r($row);
    }
    ?>
      

  3.   

    首先谢谢各位!
    不过我想问,上面的代码应该放在链接所在的页面下(index.php),还是结果显示的页面下(show.php)?
      

  4.   

    代码放在show.php
    <?php
    $id=2004;
    $query="select * from info where id='$id'";
    $result=mysql_query($query);
    $row=mysql_fetch_array($result);
    while (is_array($row))
    {
    echo $row['字段名'];
    }
    ?>
      

  5.   

    能不能再给讲一下$id传过来后怎样接收那个id变量?
      

  6.   

    #
    #index.php
    #
    <?php
    $query="select id from `info`";
    $result=mysql_query($query) or die("sql error");
    while ($row=mysql_fetch_array($result))
    {
        echo <a href=show.php?id='.$row['id'].'>'.$row['id'].'</a>';
    }
    ?>
    #
    #show.php
    #
    <?php
    $ids=$_GET['id']; //传过来的id
    echo $ids;
    echo $_GET['id'];
    //如果你还要继续查询别的东西,执行下面的程序
    if(isset($ids)||!empty($ids)){
      $query="select * from `info` where id='$ids'";
      $result=mysql_query($query) or die("sql error");
      while ($row=mysql_fetch_array($result))
      {  
         echo '你在index.php点击的 id 是'.$row['id'];
         echo '文章标题是'.$row['news_title'];//别的字段也可以这样实现
      }
    }else{
      echo '非法操作';
    }
    ?>