“php code for comment system” Code Answer


php code for comment system
php by Jolly Jackal on Aug 08 2020 Donate
0
"; $comment_info = array( 'comment' => $comment, 'comments_count' => getCommentsCountByPostId(1) ); echo json_encode($comment_info); exit(); } else { echo "error"; exit(); } } // If the user clicked submit on reply form... if (isset($_POST['reply_posted'])) { global $db; // grab the reply that was submitted through Ajax call $reply_text = $_POST['reply_text']; $comment_id = $_POST['comment_id']; // insert reply into database $sql = "INSERT INTO replies (user_id, comment_id, body, created_at, updated_at) VALUES (" . $user_id . ", $comment_id, '$reply_text', now(), null)"; $result = mysqli_query($db, $sql); $inserted_id = $db->insert_id; $res = mysqli_query($db, "SELECT * FROM replies WHERE id=$inserted_id"); $inserted_reply = mysqli_fetch_assoc($res); // if insert was successful, get that same reply from the database and return it if ($result) { $reply = "
" . getUsernameById($inserted_reply['user_id']) . " " . date('F j, Y ', strtotime($inserted_reply['created_at'])) . "

" . $inserted_reply['body'] . "

reply
"; echo $reply; exit(); } else { echo "error"; exit(); } }
php code for comment system
php by Jolly Jackal on Aug 08 2020 Donate
0

php code for comment system
php by Jolly Jackal on Aug 08 2020 Donate
0

0 Comment(s)


Melvine Apr 24, 2018

This is the first reply to this post on this website.

reply
Awa Apr 24, 2018

Hey, why are you the first to comment on this post?

reply
Source: codewithawa.com


PHP queries related to “php code for comment system”



Learn how Grepper helps you improve as a Developer!




INSTALL GREPPER FOR CHROME



All PHP Answers

X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.