![]() |
Comments on each page??
Hi, can someone point me in the right direction. i have searched all over the net and there isn't one single one that i am looking for.
I wanted to have a comment box on each of my pages so users can comment that page. i have tons of page in my website that contains urls that end with id=45 and etc. ex: if user comment pages id=45 i don't want the comments on page id=45 to appear on id=46 thanks! 8-) |
In your table for the comments, use a row for pageId that stores the ID of the page the comment is associated with. Then on the page, you just fetch the comments with pageId = $_GET['id']. Remember to secure that for sql injections.
|
Here's my code for it, but i don't know where to place that ID_ code you gave me.
PHP Code:
|
Here's my quick edit:
Code:
<?php |
Still not working :(
Here is an example: http://www.starcraftx.com/results.ph...ame=gravedigga I type in a comment for that user, but the same comment i type in for that user show's up in every other page... http://www.starcraftx.com/results.php?setname=DoS.E http://www.starcraftx.com/results.php?setname=Im.Back PHP Code:
|
Yep your missing one thing:
$id = $_GET['id']; $queryget = mysql_query("SELECT * FROM comments"); CHANGE TO: $id = $_GET['id']; $queryget = mysql_query("SELECT * FROM comments WHERE id = '$id'"); That will make sure it only selects that comments ... Not every comment which loops through and just outputs the last on all pages. |
Yeah looks like your missing a few other things as well.
When you insert the comment you need to insert it with an ID of the page .. So that you can call them all later on. Using Int is normally better then using Text or Varchar matching. (Faster) The code I typed originally had some other changes .. (on the insert statement) |
well, when i entered
PHP Code:
PHP Code:
|
Well yes ... id needs to be passed in the url for it to work, and needs to be stored in the database when you create the comment.
Basically you need to tie everything together, When the comment is added you need to insert an identifier of the page .. Normally I just us an ID # for speed.. Then when you select the page .. you select the comment records with that same ID number... Seeing as you are already passing: setname=DoS.E It might be easier to change things slightly, when adding the comment add in the setname as the unique identifier in the comments db .. then when you select ... select by setname .. Clear as mud? :) The main reason i'm trying to push to ID is because if the site gets larger and the DB for comments gets large you want to have an INT field not TEXT/VAR for the joinning. |
Well i sort of got this script to work, alright here is the problem.
When i go to MY ADMIN PHP and manually insert some dummie data's it works. but when i go to a user's page and type in some comments, it doesn't display. you can try it here, http://www.starcraftx.com/results.php?id=103 anyone seem to know whats wrong??? thanks! PHP Code:
|
Your insert query doesn't insert the id of the page together, that's why you can't link the specific comment to the page. Try something like
Code:
INSERT INTO members VALUES ($id, '$name', '$message') |
| All times are GMT. The time now is 07:37 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0