Ask again the question that this post responds to

Source: Internet
Author: User
Imitation of the Baidu Bar is an effect on the Post list page click on a post title to enter this post homepage I was the click on which title to post what title value to the database query data click into the post of the author and the title of the content display I also added a reply to the function Insert the submitted reply data into one from the table inside my problem is because the reply is completed on this page when the Post reply action completed post title and author content These things do not receive the post value of the data can not go to the database query, so will report an error. So how can you always query the title of the post and the author of these things? If you make an if judgment if you receive a post value, query the contents of the database normally if you do not receive a value what should I do with it?


Reply to discussion (solution)

Post list page Click on a post title to go to this post homepage
And this post home page shows the content of posts and replies, and there is a reply to the form, submitted to this page
Because the Post ID is passed in from the Posts list page when you go to the Post homepage, the form that you reply to will also need to have the post ID.
In fact, the reason is very simple, if you do not bring the post ID, you can not know the answer is to whom

The workflow for the Post home page is:
Check whether a form is submitted
If it is, it will reply to the inbound
Reads the contents and replies from the table by the incoming post ID and displays them

Post list page Click on a post title to go to this post homepage
And this post home page shows the content of posts and replies, and there is a reply to the form, submitted to this page
Because the Post ID is passed in from the Posts list page when you go to the Post homepage, the form that you reply to will also need to have the post ID.
In fact, the reason is very simple, if you do not bring the post ID, you can not know the answer is to whom

The workflow for the Post home page is:
Check whether a form is submitted
If it is, it will reply to the inbound
Reads the contents and replies from the table by the incoming post ID and displays them



I know what you're saying. However, the post value of the jump when I submit a reply to the page. If you submit a reply, this page will not receive the post value ah then how to query the display Ah, such as the current page address is http://localhost/tieba3.php?id=4 When I submit a reply, how to make the address bar or id=4?

Since the reply is submitted to this page, the action on the form does not need to be written
The URL parameter when entering the program does not become

Complete code attached

Posts List page








Include "cookie.php";
echo $_cookie[' username '];
?>




Include ' function.php ';
Header (' content-type:text/html;charset=utf-8; ');
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
$stmt = $pdo->prepare ("SELECT * from Tieba");
$stmt->execute ();
$res = $stmt->fetchall ();
$rows =count ($res);//total number of bars
$pagesize = 8;
if ($rows ==0) {
$pagenum = 0;
}else{
$pagenum =ceil ($rows/$pagesize);//divided into several pages
}
if (Isset ($_get[' page ')) {
$page =$_get[' page ';
if (Empty ($page) | | $page <0| |! Is_numeric ($page)) {
$page = 1;
}else{
$page =intval ($page);
}
}else{
$page = 1;
}
if ($page > $pagenum) {
$page = $pagenum;
}
$startnum = ($page-1) * $pagesize;
$display _page=5;
$query = "SELECT * from Tieba LIMIT $startnum, $pagesize";
$stmt 2= $pdo->prepare ($query);
$stmt 2->execute ();
$res 2= $stmt 2->fetchall (PDO::FETCH_ASSOC);
foreach ($res 2 as $v) {
Echo '

  • '. $v [' title ']. '
  • ';
    }
    ?>


    Fenye ();
    ?>










    Posts Home



    <title></title>




    Include "cookie.php";

    ?>




    if (isset ($_get[' title ')) {
    echo $_get[' title ';
    $pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
    $title =$_get[' title ';
    $stmt = $pdo->prepare ("Select Id,title,type,name,num,site,content from Tieba where title=?");
    $stmt->execute (Array ($title));
    $res 3= $stmt->fetchall (PDO::FETCH_ASSOC);
    foreach ($res 3 as $v) {
    Echo '. $v [' num ']. ';
    $id 1= $v [' id '];
    }
    }else{
    echo $id 1;
    }

    ?>






    $id 2= $v [' id '];
    $pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
    $stmt = $pdo->prepare ("Select id,name,content from reply where reid=?");
    $stmt->execute (Array ($id 2));
    $res 1= $stmt->fetchall (PDO::FETCH_ASSOC);
    foreach ($res 1 as $v 2) {
    echo $v 2[' name '];
    }
    ?>








    Since the reply is submitted to this page, the action on the form does not need to be written
    The URL parameter when entering the program does not become




    Oh, thank you so much. Moderator
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.