Adding On To My Comment/News System

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

38 Replies - 5307 Views - Last Post: 16 October 2011 - 08:33 PM Rate Topic: -----

#1 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Adding On To My Comment/News System

Posted 15 October 2011 - 12:19 PM

So heres my website... http://mechanicalgamer.com/index.php

Its pretty simple all made in notepad the past few days. I'm trying to get a news system that can be updated via the website without knowing any code or anything. I have a simple comment system set up for the "news1.php", you can click read more under news1 on the front page to get there. It just inserts the posted information into a table from the form and it is echoed back out there.

I know I may be getting a little bit over my head with this, but I'm up for a challenge.

Basically, I want to know the best way to go about setting up a pretty advanced comment and news system. I want ever news page to have its own comment section - does that require me to have it make a new SQL table for each news section and setting the columns everything automatically... I'd love to try to do this but I have no idea how to start.

Tl;dr I want to put a comment section on every news page created automatically - like the comment section I have on news1.php already.

Feel free to ask me more questions I will stalk this topic.. I probably left a lot out. Hope you understand this!! haha

<3333

Is This A Good Question/Topic? 0
  • +

Replies To: Adding On To My Comment/News System

#2 Duckington  Icon User is offline

  • D.I.C Addict

Reputation: 169
  • View blog
  • Posts: 606
  • Joined: 12-October 09

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 12:44 PM

News table:

newsID
newsTitle
newsContent
newsDate

Comments Table:

commentID
newsID
commentContent
commentDate


Just have a field in the comments table to reference a particular news item. Then when dispaying an item of news, check for any comments with that newsID.
Was This Post Helpful? 1
  • +
  • -

#3 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 12:47 PM

Alright, I'm gonna try this thanks!

This post has been edited by JackOfAllTrades: 15 October 2011 - 02:22 PM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0
  • +
  • -

#4 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:21 PM

Ok I'm stuck.

How do I give a table itself an ID that auto increments per every table I make? I can only figure out how to do this with columns. Because I need to link comment table id with news table id.

This post has been edited by JackOfAllTrades: 15 October 2011 - 02:22 PM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:23 PM

You don't create new tables. You only have the two that Duckington suggested. Everything goes in them, and newsID is an auto incrementing primary key.

This post has been edited by CTphpnwb: 15 October 2011 - 01:56 PM

Was This Post Helpful? 0
  • +
  • -

#6 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:32 PM

View PostCTphpnwb, on 15 October 2011 - 01:23 PM, said:

You don't create new tables. You only have the two that Ravage suggested. Everything goes in them, and newsID is an auto incrementing primary key.


But if its auto incrementing I would only have 1 comment per news section, unless I do like id 1-10... but that would be a random guess.
Was This Post Helpful? 0
  • +
  • -

#7 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:42 PM

Huh? No, the newsID would be an auto incrementing key in the News table and referenced in the comments table, where the commentID would be an auto incrementing key.
Was This Post Helpful? 0
  • +
  • -

#8 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:43 PM

Oooooh ok I see what hes saying but that makes it a lot less user friendly, I would rather the news bring in the comments not have the writer put the comments in a certain news area.
Was This Post Helpful? 0
  • +
  • -

#9 Crazy_Learner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 145
  • Joined: 25-July 09

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:45 PM

what hes trying to say is that the key is auto incremental on the newsId column in the new table; not in the comments table. the primary id in the comments table is the commentsID. then the comment table contains the newsId which will allow you to determine by sql all statements with that news id in the comment table

EDITED; Stated Above -- IGNORE POST --

View PostRavage, on 15 October 2011 - 10:43 PM, said:

Oooooh ok I see what hes saying but that makes it a lot less user friendly, I would rather the news bring in the comments not have the writer put the comments in a certain news area.


the client will not have to post to a specific news area as the user will enter the comment and your php would input the newsId into the comment table

This post has been edited by Crazy_Learner: 15 October 2011 - 01:44 PM

Was This Post Helpful? 0
  • +
  • -

#10 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:48 PM

View PostCrazy_Learner, on 15 October 2011 - 01:45 PM, said:

what hes trying to say is that the key is auto incremental on the newsId column in the new table; not in the comments table. the primary id in the comments table is the commentsID. then the comment table contains the newsId which will allow you to determine by sql all statements with that news id in the comment table

EDITED; Stated Above -- IGNORE POST --

View PostRavage, on 15 October 2011 - 10:43 PM, said:

Oooooh ok I see what hes saying but that makes it a lot less user friendly, I would rather the news bring in the comments not have the writer put the comments in a certain news area.


the client will not have to post to a specific news area as the user will enter the comment and your php would input the newsId into the comment table



I would rather it depend on where the users coming from and be automatic, not manual. Any way to do this?

Ok, I'm still pretty newbie to PHP. Not exactly sure how I would do that. Can you show me? <3

This post has been edited by JackOfAllTrades: 15 October 2011 - 02:24 PM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0
  • +
  • -

#11 Crazy_Learner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 145
  • Joined: 25-July 09

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:48 PM

the only way to achieve that is to use session, post or get variables from the page the user is coming from and gather that variable information in your news page that they go to.
Was This Post Helpful? 0
  • +
  • -

#12 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:48 PM

Maybe this will make it clearer. Suppose you know the newsID and want to find all comments related to it. Your query might look like this:
SELECT commentContent, commentDate FROM Comments WHERE newsID = ? ORDER BY commentID

Was This Post Helpful? 0
  • +
  • -

#13 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:50 PM

View PostCTphpnwb, on 15 October 2011 - 01:48 PM, said:

Maybe this will make it clearer. Suppose you know the newsID and want to find all comments related to it. Your query might look like this:
SELECT commentContent, commentDate FROM Comments WHERE newsID = ? ORDER BY commentID



Yeah I'm getting that now, but how would I haver the newsID automatically entered - without the user having to do it? Sessions or something like that - which is relatively new to me. I'm down to learn though :-)
Was This Post Helpful? 0
  • +
  • -

#14 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2891
  • View blog
  • Posts: 10,025
  • Joined: 08-August 08

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 01:54 PM

You might have a query that looks like this:
SELECT newsID, newsTitle, newsDate from News

which you then use to display links. When a user clicks on a link the newsID is passed to PHP, which uses it in the previously shown query to retrieve comments.

This post has been edited by CTphpnwb: 15 October 2011 - 01:55 PM

Was This Post Helpful? 0
  • +
  • -

#15 Ravage  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 15-October 11

Re: Adding On To My Comment/News System

Posted 15 October 2011 - 02:22 PM

Ok well first I'm going to set up multiple news pages the correct way. I'm just having 1 table for all of the news pages, and echo out 1 , 2 , 3 etc for each news page.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3