如何把这里<li><a href="only.php">第<?=$row['0'];?>个帖子</a><li>输出的记录在only页面得到

解决方案 »

  1.   

    如何把这里<li><a href="only.php">第<?=$row['0'];?>个帖子</a><li>输出的记录在only.php这个程序文件里面得到,对吗?
    还是不明白你是啥意思啊~~~
      

  2.   

    <li><a href="only.php?id=<?=$row['0'];?>">第<?=$row['0'];?>个帖子</a><li>
      

  3.   

    不好意思 我是说如何把第一个页面里的<li><a href="only.php">第<?=$row['0'];?>个帖子</a><li>
    $row['0'],给它送到第二个页面去only.php,
      

  4.   

    你看看二楼的,常用的方法通过url传参数数据接收通过$_GET['id'];即可
      

  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=gb2312" />
    <title>查看所有帖子页面</title>
    </head><body>
    <?

        $mysql_server_name = "localhost";
    $mysql_username    =  "lipichang";
    $mysql_password    =  "123456";
    $mysql_database    =   "lyb";

    //建立连线————透过(服务器地址,使用名称,密码)
    $conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

    $sql = "SELECT * FROM `newinsert`";

    mysql_select_db($mysql_database,$conn);

    mysql_query("SET NAMES 'gbk'");

    $result = mysql_query($sql);

    while($row = mysql_fetch_array($result))
    {

    $id=$row[0];
    ?>

    <li><a href="only.php">第<?=$row['in_id'];?>个帖子</a><li>
    发表人:<?=$row['1']."先生(小姐)";?>
    <li><a href="only.php">标题:<?=$row['2'];?></a></li>
    <li>发表时间:<?=$row['4'];?></a></li>
    <? echo "<P>-------------------------------------------------------<P>";?>
    <?
    }
    mysql_free_result($result);
    ?>
    </body>
    </html>
      

  6.   

    only.php<!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=gb2312" />
    <title>查看帖子单独页面</title>
    </head><body>
    <?
    $in_id = $_REQUEST['in_id'];
        $mysql_server_name = "localhost";
    $mysql_username    =  "lipichang";
    $mysql_password    =  "123456";
    $mysql_database    =   "lyb";
    echo $in_id;

    //建立连线————透过(服务器地址,使用名称,密码)
    $conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);

    $sql = "SELECT * FROM `newinsert` where in_id = ".$in_id;

    echo $sql;

    mysql_select_db($mysql_database,$conn);

    mysql_query("SET NAMES 'gbk'");

    $result = mysql_query($sql);


    while($row = mysql_fetch_row($result))
    {
     print_r($result);

    }?></body>
    </html>
      

  7.   

    <li><a href="only.php">第<?=$row['in_id'];?>个帖子</a><li>
    改成
    <li><a href="only.php?in_id=<?php echo $row['in_id'];?>">第<?=$row['in_id'];?>个帖子</a><li>
      

  8.   

    报错如下 SELECT * FROM `newinsert` where in_id = 
    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in F:\AppServ\www\only.php on line 31
      

  9.   


    列表页程序文件里面
    “ <li><a href="only.php">第<?=$row['in_id'];?>个帖子</a><li>”应该改为:
      <li><a href="only.php?id=<?=$row['in_id']?>">第<?=$row['in_id'];?>个帖子</a><li>
    ------------------------
    详细页 only.php 里面代码如下:<!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=gb2312" />
    <title>查看帖子单独页面</title>
    </head><body>
    <?
        //$in_id = $_REQUEST['in_id'];
        $in_id = intval($_GET['in_id']);
        if($in_id <= 0) exit('BAD_REQUEST');    $mysql_server_name = "localhost";
        $mysql_username    =  "lipichang";
        $mysql_password    =  "123456";
        $mysql_database    =   "lyb";
        echo $in_id;    //建立连线————透过(服务器地址,使用名称,密码)
        $conn=mysql_connect($mysql_server_name,$mysql_username,$mysql_password);    mysql_select_db($mysql_database,$conn);    mysql_query("SET NAMES 'gbk'");    $sql = "SELECT * FROM `newinsert` where in_id = ".$in_id;    echo $sql;    $result = mysql_query($sql);
        while($row = mysql_fetch_row($result))
        {
             //print_r($result);
             print_r($row);    }?></body>
    </html>
      

  10.   


    哦,写错了,是参数是 in_id= 而不是 id= 
      

  11.   

    <li><a href="only.php?in_id=<?php echo $row['in_id'];?>">第<?=$row['in_id'];?>个帖子</a><li>
    only.php
    <?
        $in_id = $_REQUEST['in_id']; //获取第几个帖子传过来的参数in_id$sql = "SELECT * FROM `newinsert` where in_id = ".$in_id;
        
        echo $sql;//$sql 输出是什么。。