Results 1 to 10 of 10

Thread: While loop through comments

  1. #1
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cool While loop through comments

    I have a while loop that loops through the comments for a particular blog and displays them. Everything works great there, and it shows every comment related to the blog.

    I want users to be able to reply to comments posted, so I have this form that pops up (using javascript) with a text box when someone clicks "reply" under the comment. I just added this Reply link and what happens is that when the link is clicked it only shows the reply box under the first comment, no matter what reply link was clicked (for ex: if it was clicked on the tenth comment, it'll still show under the first comment as a reply to the first comment. If I remove the reply link and just display the reply boxes, they all show up with the right commentid under the appropriate comment. It's just when I have the link that causes the problem.

    How can I get the reply link to pull up the reply box under the appropriate comment and associated to the appropriate commentid?

    Hope this makes sense, any help would be appreciated!

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Can you post either a link to the page you want this done on or at least the source code? This will help us out a lot.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Ok i think i took off all the validation....

    here's the link
    (link removed)
    Thanks!!
    Last edited by jnscollier; 05-20-2007 at 07:44 PM.

  4. #4
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Oh yeah, the reply itself is not functioning yet... I'm just trying to get the form positioned correctly first... I don't know if that matters.

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You are calling the showForm function with the same id for every link. In other words, you are showing it like so:

    Code:
    <a href="#" onclick="showForm('theForm2'); return false;">Reply</a>
    for every "Reply" link. What you could do (in the while loop of the PHP code) is assign a value for each comment (1,2,3...) by simply using the "id" or "count" of the comment. This goes for the div id as well.

    Hope this helps and makes sense.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Each comment currently is associated with a commentid... is that what you're talking about? I guess my question is... do i need to add something to the reply link to make it work properly?

    Code:
    $cmtqry="select * from ".BLOG_COMMENTS." where eparent='".$HTTP_GET_VARS['blogid']."' order by commentId ASC Limit $start , $rows_per_page";
    				$cmtres=mysql_query($cmtqry);
    				$cmtrows=mysql_num_rows($cmtres);
    				if($cmtrows > 0){
    				while($cmtarr=mysql_fetch_array($cmtres)){

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Yes, for your while loop (where you display the comments and create the link and form) you will need to do something like this:

    Code:
    <a class="privacylink" href="#" onclick="showForm('<?php echo $commentID;?>'); return false;">Reply</a>  &nbsp;&nbsp;
    	
    	<div id="<?php echo $commentID;?>" style="display: none;">
    
    <form action="replycomments.php" name="<?php echo $commentID;?>" method="post" onSubmit="return checkfields()">
    	<br><textarea cols= "49" rows= "3" name= "replycomment"></textarea><br>
    	<input type ="text" value="<?php echo $commentID;?>" name="commentid">
        <input type = "hidden" name= "blogid" value= "220">	 
    	 <input onClick="validate();" type="button" value="Reply" name="cmdSubmit"><input type="submit" onclick="hideForm('<?php echo $commentID;?>'); return false;" value="Nevermind">
     </form>
     
    </div>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Has anyone ever told you how awesome you are???? That worked, THANK YOU SOOOO MUCH!!!!!

  9. #9
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    So yeah, I thought that once I got the reply layout fixed (which testingsite helped me with - thanks again btw!) all my worries were over... Nope!

    I thought i would just need to make an action page and everything would work perfectly... but life isn't that easy. I'm sure I'm missing smthg so friggin obvious, but I can't figure this out and I've been working on trying to figure this out for hours now!!!

    Here's the link again:

    (link removed)

    When user hits reply to a certain comment, the comment box pops up, it's all great and dandy. EXCEPT, it will not submit (when you hit reply, nothing happens). I have an action page and everything... I don't know what the heck i'm doing wrong. I looked in IE and it says object required and I can't figure out what i'm missing. I've removed all validation and everything, any help would be appreciated you guys!
    Last edited by jnscollier; 05-21-2007 at 04:16 AM.

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You have the button that closes the reply box as the submit button, instead of the otherway around. This should fix your problem.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

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