简体   繁体   中英

Comments to every post (PHP)

Sorry if being such a noob!

I'm currently working on a blog page with posts. I have already set up a CMS where you can create new posts (with the following method..)

if(isset($_POST['submit'])) {
    if(isset($_POST['PostName'])) {
        if(isset($_POST['PostContent'])) {
            addPost($_POST['PostName'],$_POST['PostAuth'],$_POST['PostContent'],$_POST['PostCats'],$_POST['PostDay'],$_POST['PostMonth'],$_POST['PostYear'],$_POST['PostImage'],$post_count);
            header("Location: addPost.php");


        } else { "text empty";

        }

    } else {
        echo "title empty";
        include('back1.php'); 
    }

} else {
    header("Location: back2.php");
}

function addPost($pName, $pAuth, $pContent, $pCat = 1, $pDay, $pMonth, $pYear, $pImage) {   
   $query = mysql_query("INSERT INTO posts
              VALUES(null,'$pName','$pAuth',
                    '$pContent','$pCat',
                    '$pDay','$pMonth',
                    '$pYear','$pImage')") or die(mysql_error()); 
}

However, I want a unique comment field to every post.

I already know how to set up a form that that post details to the MySQL, and then a get function to view it on the page. But which method should I use if I want a unique comment field for every post? Since they can't have the same table etc...

您只应在评论表单中添加包含帖子ID的隐藏字段。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM