Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 03-23-2012, 07:40 AM
Junior Member
 
Join Date: 03-11-12
Posts: 18
iTrader: 0 / 0%
PHP/mysql can I make a comment section to comment the record?

PHP/mysql can I make a comment section to comment the record?
So everytime the record loaded, on the comment section it will show the comment about this record.

My current idea is create a new table in mysql...so my question is how it should be? Can the ID(auto ID?) on this table link to the table for the records?

But one record can have many comments...so the comment will get its own unique id? if this is the case than I can just add/remove/delete the comments...but here it come another problem...will it be too risk? as I need to gave out the mysql login details to the page so visitors can be able to add records...

can someone please give me some suggestion?

Thank you for your time and sorry about the English.
 
Reply With Quote
  #2 (permalink)  
Old 03-23-2012, 03:25 PM
ScriptMan's Avatar
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 11,968
iTrader: 4 / 100%
I am not real sure what you want to do.

Are you wanting more than one person to be able to add comments about a a 'something'? As an example say you an article and you want visitors to be able to post a comment about it?

Or are you wanting private comments that only you can see? To remind you of what the post is about?
__________________
SEO does not mean Spam Everywhere Online
Scriptman's Playhouse || Ramblings from an old man
 
Reply With Quote
  #3 (permalink)  
Old 03-23-2012, 07:23 PM
Junior Member
 
Join Date: 03-11-12
Posts: 18
iTrader: 0 / 0%
Quote:
Originally Posted by ScriptMan View Post
As an example say you an article and you want visitors to be able to post a comment about it?
This is what I want, thanks for putting it into English

Ive the table for records and it have the id for each record.
I want to add a comment section so every visitor can leave their comment on it.

I am now trying to implement a new table to insert these comments. But how can I link them together? And how can I define that these comments will stay with that record?

e.g.
Visitor 1 wrote a comment on Record A.
Visitor 2 wrote a comment on Record A.
Visitor 3 wrote a comment on Record C.
Visitor 4 wrote a comment on Record B.
Visitor 5 wrote a comment on Record A.
Visitor 6 wrote a comment on Record B.


Comment section on Record A's page will show Visitor 1, Visitor 2 and Visitor 5 comments.
Comment section on Record B's page will show Visitor 4 and Visitor 6 comments.
Comment section on Record C's page will show Visitor 3 comment.

Thank you for your help.
 
Reply With Quote
  #4 (permalink)  
Old 03-24-2012, 01:59 AM
kontrol's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 02-10-10
Posts: 200
iTrader: 0 / 0%
what you have to do is that you, in the php script that will insert the comments into the new table, create a column that will contain the id of the record the commenter is commenting on. it should not be unique and then in the form for the input, add a hidden field to hold the id of the record as its value. In this way, you will retrieve all comments on a record using IN your sql statement. example $select = "SELECT * FROM comments WHERE recordID IN ('$id')";
__________________
this is the best forum i have ever been to!!!!
 
Reply With Quote
  #5 (permalink)  
Old 03-24-2012, 03:52 AM
ScriptMan's Avatar
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 11,968
iTrader: 4 / 100%
What he said!

On the page where the initial posts appears you need to capture the post ID and use that to insert the comment into the new table along with the comment and any related information.

The table for the comments section may or may not contain all of the following:
comment ID, indexed, unique, auto increment
post ID, possible index
date
IP number of commenter
status (allows you to control visible or not)
comment (the text portion)
abuse reports ( a numeric value to determine visible or not IE: 0 or 1)
reported by (record the IP number of the person reporting abusive posts)

The table may contain other information. I just hit the more common basic items.
__________________
SEO does not mean Spam Everywhere Online
Scriptman's Playhouse || Ramblings from an old man
 
Reply With Quote
  #6 (permalink)  
Old 03-24-2012, 08:13 PM
Junior Member
 
Join Date: 03-11-12
Posts: 18
iTrader: 0 / 0%
Will try to post the code here tomorrow to see what went wrong...

meanwhile a side question, if I finish the website, can you people have a look at it and give me some feedback to improve it? as this is the first time I use php+mysql to build a website.

If so, I should zip all the pages via 7-zip or just post all the codes?


thank you for your time.
 
Reply With Quote
  #7 (permalink)  
Old 03-25-2012, 05:09 AM
ScriptMan's Avatar
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 11,968
iTrader: 4 / 100%
Anything you post in its entirety anywhere online may create some future security issues for you. It may never be a problem but it could be. Posting snippets or code where you have changed a few values that you fully understand is okay.

Why don't you start by telling us what problem you are experiencing.
__________________
SEO does not mean Spam Everywhere Online
Scriptman's Playhouse || Ramblings from an old man
 
Reply With Quote
  #8 (permalink)  
Old 04-04-2012, 02:16 PM
Junior Member
 
Join Date: 03-11-12
Posts: 18
iTrader: 0 / 0%
Was busy in the past 2 weeks...anyway in these 2 weeks Ive figured out how to insert some more function that will work on my site. (e.g.img upload...searching...login...)

anyway, its time for me to come back into this feedback(comments) function.

Now, Ive another idea...

inside the user submit button, add this line
<input type="hidden" name="name" value="<?php echo $name ?>">

a new mysql table will include these fields

id(auto id), userid, email, comments and cmtName

cmtName is for inserting this $name above.
e.g. $cmtName = $_POST['name'];

So whenever these comments section load, it will have mysql query like

SELECT * FROM feedback WHERE cmtName = '$name'

and the php generate all comment which have the same $name...

Will the feedback work this way?

Thank you for your time.
 
Reply With Quote
  #9 (permalink)  
Old 04-04-2012, 04:56 PM
ScriptMan's Avatar
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 11,968
iTrader: 4 / 100%
if $cmtName = $_POST['name']; is a a unique item in the DB it should. Do you not assign id numbers to the original post? One unique id number per name?
__________________
SEO does not mean Spam Everywhere Online
Scriptman's Playhouse || Ramblings from an old man
 
Reply With Quote
  #10 (permalink)  
Old 04-04-2012, 07:17 PM
Junior Member
 
Join Date: 03-11-12
Posts: 18
iTrader: 0 / 0%
Just think of one thing...the cmtName can be edit...so its a no go and why I am so dump...I already assign the id(auto id) for this table...I should just use it...
.......................................

*facepalm* wasnt this is what you guys trying to tell me 2 weeks ago...anyway, its 3am now so I will try to this tomorrow

I used to be writing C+...but why I am so dump in php...
 
Reply With Quote
  #11 (permalink)  
Old 04-05-2012, 06:03 PM
Junior Member
 
Join Date: 03-11-12
Posts: 18
iTrader: 0 / 0%
sorry for making another reply as I cannot edit the above post.

anyway, ive sorted this problem.

This query is working fine.
"SELECT * FROM comments WHERE recordID IN '$id'";

Thanks again for all of your help.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Comment Section for Site chappyk Web Design Lobby 10 01-31-2012 05:13 AM
Help With Comment Section chappyk Coding Forum 3 11-10-2011 05:03 PM
Comment section issue Lainika Coding Forum 1 08-16-2010 03:14 PM
Need help adding comment section only_8s Coding Forum 3 02-18-2009 06:34 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:50 AM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2014 Escalate Media




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.