Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. $user_id = 1;
  2. // connect to database
  3. $db = mysqli_connect("localhost", "root", "", "comment-reply-system");
  4. // get post with id 1 from database
  5. $post_query_result = mysqli_query($db, "SELECT * FROM posts WHERE id=1");
  6. $post = mysqli_fetch_assoc($post_query_result);
  7.  
  8. // Get all comments from database
  9. $comments_query_result = mysqli_query($db, "SELECT * FROM comments WHERE post_id=" . $post['id'] . " ORDER BY created_at DESC");
  10. $comments = mysqli_fetch_all($comments_query_result, MYSQ
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement