This article mainly introduces the function of imitating the publishing dynamics, comments, replying to comments, and deleting dynamic or comments in the QQ space or circle of friends (medium ), for more information, see this article. it mainly describes the function of imitating the QQ space or circle of friends to publish dynamic, comment dynamic, reply to, delete dynamic or comment (medium). For more information, see
How to publish and dynamically present the content in the previous article. now let's take a look at the remaining comment dynamics, reply to comments, delete dynamic content, and comment functions. these functions will be a bit different ~~~
I. The idea is as follows:
(1) when you post a dynamic Review, someone will comment on the dynamic Review. after the review, you will also reply to the comment. (a separate table is required for the comment here, A separate table is required for the reply)
(2) delete dynamic: all dynamic comments and replies will be deleted; delete comment: only this comment will be deleted.
2. before writing the code, I still want to explain the process again:
(1) publish a dynamic post-Comment-reply-Reply
(2) to refine the above process, I first write it on paper and then upload it. the code word cannot be clearly expressed (note that the implementation of the function I want, not exactly)
Strquery ($ SQL); echo "welcome:". "{$ name}";?>
Step 1: comment
1. comment on James's dynamics. click "OK", and the second figure is displayed ~
// Define an empty string that contains the comment id var code = ""; $ (". pl "). click (function () {code = $ (this ). attr ("code"); // revalue the comment id}) // write the comment into the database $ ("# tjpl "). click (function () {var plnr = $ (". pldt "). val (); var plid = code; // Obtain the dynamic id $. ajax ({url: "pl-cl.php", data: {plnr: plnr, plid: plid}, type: "POST", dataType: "TEXT", success: function (data) {alert ("comment successful! "); Window. location. href = "main. php "rel =" external nofollow "rel =" external nofollow ";}});})
Pl-cl.php web page
query($sql,0);?>
Check if the qqpinglun table contains this "why are you happy ?" :
Query ($ SQL); foreach ($ arr as $ v) {$ SQL = "select * from qqdongtai where dtid = '{$ v [1]}'"; $ arr2 = $ db-> query ($ SQL); foreach ($ arr2 as $ m) {// Obtain the dynamic name $ SQL = "select name from qqusers where uid = '{$ v [2]}'"; $ name = $ db-> strquery ($ SQL); // if the comment is sent, "I" is displayed. if ($ v [2] = $ uid) {$ name = "I ";} // Obtain the name of the reviewer $ SQL = "select name from qqusers where uid = (select uid from qqdongtai where dtid = '{$ v [1]}')"; $ bpl = $ db-> strquery ($ SQL); echo"
Dynamics of {$ name} comments {$ bpl}: {$ m [2]}
{$ V [3]}
Comment Time: {$ v [4]}
ReplyDelete comment
";}}?>
Step 2: reply
1. reply to the previous comment:
2. write the reply content into the database
// Define an empty string that contains the id var ids = ""; $ (". hf "). click (function () {ids = $ (this ). attr ("ids"); // revalue the comment id // alert (ids); $ ('# MM '). modal ('show');}) // write the reply comment to the database $ ("# tjhf "). click (function () {var hfnr = $ (". hfpl "). val (); // alert (hfnr); // alert (ids); $. ajax ({url: "hf-cl.php", data: {hfnr: hfnr, ids: ids}, type: "POST", dataType: "TEXT", success: function (data) {alert ("reply successful! "); Window. location. href = "main. php "rel =" external nofollow "rel =" external nofollow ";}});})
Hf-cl.php web page
query($sql,0);?>
Check the qqhuifu table. Is there an additional row?
Query ($ SQL); foreach ($ arr as $ a) {$ SQL = "select * from qqpinglun where cid = '{$ a [1]}'"; $ arr2 = $ db-> query ($ SQL); foreach ($ arr2 as $ n) {// Retrieve the dynamic comment name $ SQL = "select name from qqusers where uid = '{$ a [2]}'"; $ name = $ db-> strquery ($ SQL); // if the comment is sent, "I" is displayed. if ($ a [2] = $ uid) {$ name = "I ";} // Get the name of the comment replied $ SQL = "select name from qqusers where uid = (select uid from qqpinglun where cid = '{$ a [1]}')"; $ bpl = $ db-> strquery ($ SQL); echo"
{$ Name} replied to {$ bpl}'s comment: {$ n [3]}
{$ A [3]}
Reply Time: {$ a [4]}
ReplyDelete Reply
";}}?>
The reply content is displayed as follows:
query($sql,0);$sql2 = "delete from qqpinglun where dtid='{$code}'";$db->query($sql2,0);$sql3 = "delete from qqhuifu where cid=(select cid from qqpinglun where dtid='{$code}')";$db->query($sql3,0);header("location:main.php");?>
2. delete comments: (including replies)
Scpl-cl.php
query($sql2,0);$sql3 = "delete from qqhuifu where cid='{$code}'";$db->query($sql3,0);header("location:main.php");?>
3. delete the reply: (only yourself)
Schf-cl.php
query($sql2,0);$sql3 = "delete from qqhuifu where cid='{$code}'";$db->query($sql3,0);header("location:main.php");?>
I will not try to delete it in sequence ~~~ Pay attention to the inclusion relationship.
All code on the home page: