Jump to content

Blaze

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Blaze

  1. You will need a column in your comments table to tell which news story it goes with. So, your comments table needs a field like "news_id". Your links to add a comment will have to include the ID of the news story on the link, like this:add_comment.php?id=7
    I know that I need the link to show up like that, the thing is, I don't want to do it by opening each page and giving it an id.I was thinking along the lines of when clicked on the "add a comment" part, it would somehow read the comment's id and then have the id as a variable on the typing part, so that i can use that and add it to the comment's mysql table as a news_id or something similar. The thing is i dont know how to do that...
    Or whatever the ID is, when you are displaying information about the news from the database, include the ID in your link. Then, when they click on that link to add the comment, you know which news story they are commenting on. You can get the news ID on the add_comment page using this:$news_id = $_GET['id'];
    This gives me an idea. I'm adding the "Add a comment-view comments" button via php, right after the news are posted. So i assume i can make the link using POST variables? like:
    $id=$_POST(id);echo '<a href='addcomments.php?[b]id=$id[/b]'>Add a comment</a> - <a href='viewcomments.php?[b]id=$id[/b]>View Comments</a>';

    But its the bold part what im not sure of (the id=$id).

    And you will probably want to add it as a hidden input field on your comment form:<input type="hidden" name="news_id" value="<?php echo $news_id; ?>">
    Wait a second, what did you just did there? Make an invisible input with the value of the old id, what for? I lost myself there.
    $news_id = intval($_GET['id']);$result = mysql_query("SELECT * FROM comments WHERE news_id={$news_id}");

    Lastly, what does that intval mean? interval or is it one of mysql data types?Thanks a lot for your help.

  2. Alright, i'll try to explain myself the best i can. I'm spanish, my english isn't great. So please... bear with me. Thanks in advance to anyone that tries to help.I was learning php, and trying to add a "Add a comment" for the news section on my site. I managed to make the add a comment page, and the view comments page. Now, here is the issue.For example, i have two news on the frontpage, both with different id (on the mysql table). But whenever i click the view comments page, it shows the comments for BOTH. That's because I know i should use a WHERE clause on the mysql command for loading the comments, based on news id. My issue here is,I don't know how to make the "add a comment" page have the news id added dinamically so that it can be read later only if the same id is on the comments. Im not sure if i make myself clear...http://www.dfblaze.net/index2.phpGo there, and try to add a comment to the FIRST news post. Then view the comments for the second one, and you'll see the same comments. I hope i made myself clear now. :)Thanks to anyone, again. I've been struggling with this all day.

    • Like 1
×
×
  • Create New...