Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2011
    Posts
    114
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Help me on commenting on a post in the same page

    Hi

    I desperately need help on how to allow users to post comment and also let users to comment on that paticular post on the same page..

    Please i have done the post script and it works correctly but how to let them comment on the post on the same page...can someone help me out or can direct me to a tutorial that teaches that

    Thanks

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    You need to decide on a few things before you continue ...

    1) Will anyone be able to comment, or only logged-in users?
    This might be a real bad issue with spammers who will post hundreds of comments.

    2) Will the comment editor be a plain text box, or RTF (rich type format), such as
    the editor you used for typing your post?

    3) Is there an "admin" section required to edit or delete posts? And who will be
    able to do that? Multiple admin users (moderators)?

    4) Might it be better to install a WordPress site and use that framework for your site?

  • #3
    Regular Coder
    Join Date
    Feb 2011
    Posts
    114
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hi Sir,

    It only registered users that can post comment and can comment on the post too as anyone can post on his post too in the same page as facebook and youtube does,

    The post area is only textarea that will be provided to type and post comment.
    Also the user can delete his post and i will provide pagination to all commments..!!

    Now i have done the comment where when you comment your picture and name and comment appears good. All the comment will have a small textarea and a button to comment on that post comment..

    Now when i try to comment on a post ..it did alright but it repeat to all comment on the page and the west thing is that ..if 10 comment on a page with each underneath a submit button, it will add up all 10 on each comment post i comment on..

    Hard to understand what i mean here

    but here is the code
    PHP Code:
    //here is the main comments post function
    function post_kon($konkon){
    $konkon=mysql_real_escape_string($konkon);
    mysql_query("INSERT INTO `konkonsa` (`kon_id`,`user_id`,`kon_post`,`kon_date`) VALUES('','".$_SESSION['user_id']."','$konkon',Now())");

    }


    function 
    display_kon(){
    $kon=array();
    $sql=mysql_query("SELECT
    `kon_id`,
    `users`.`user_id`,
    `users`.`firstname`,
    `users`.`lastname`,
    `kon_post`,
    `kon_date`
    FROM `konkonsa` INNER JOIN `users` ON
    `users`.`user_id`=`konkonsa`.`user_id` ORDER BY `kon_id` DESC
    "
    );

    while(
    $row=mysql_fetch_assoc($sql)){
    $row['avatar']=(file_exists("user_avatars/{$row['user_id']}.jpg")) ?"user_avatars/{$row['user_id']}.jpg" "user_avatars/default.jpg";
    $row['kon_id'];
    $row['user_id'];
    $row['firstname'];
    $row['lastname'];
    $row['kon_post'];
    $row['kon_date'];

    $kon[]=$row;
    }
    return 
    $kon;

    }
    //maian post function ends here



    //reply to a comment function here
    function display_reply(){
    $reply=array();
    $sql=mysql_query("SELECT
    `reply_id`,
    `users`.`user_id`,
    `users`.`firstname`,
    `users`.`lastname`,
    `reply_post`,
    `reply_date`
    FROM `kon_reply` INNER JOIN `users` ON
    `users`.`user_id`=`kon_reply`.`user_id` ORDER BY `reply_id` DESC
    "
    );

    while(
    $row=mysql_fetch_assoc($sql)){
    $row['avatar']=(file_exists("user_avatars/{$row['user_id']}.jpg")) ?"user_avatars/{$row['user_id']}.jpg" "user_avatars/default.jpg";
    $row['reply_id'];
    $row['user_id'];
    $row['firstname'];
    $row['lastname'];
    $row['reply_post'];
    $row['reply_date'];

    $reply[]=$row;
    }
    return 
    $reply;

    }

    function 
    post_reply($kon_reply){
    $kon_reply=mysql_real_escape_string($kon_reply);
    mysql_query("INSERT INTO `kon_reply`(`reply_id`,`user_id`,`reply_post`,`reply_date`) VALUES('','".$_SESSION['user_id']."','$kon_reply',Now())");
    }
    //reply comment post ends here
    ?> 

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,472
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I need to see a page where the comments appear, and where it fails.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •