4 Replies - 424 Views - Last Post: 12 September 2011 - 09:14 AM Rate Topic: -----

#1 PixelBit  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 233
  • Joined: 17-July 11

Comments/ other things that could be added to infanately

Posted 12 September 2011 - 08:45 AM

After now feeling pretty comfortable with php and mysql I decided to take on a new project, tat is to make a client managing web application. I have all the pages mapped out and such, and how it will all work and fit together. However i have a few gaps in my knowledge.

How do i make thing that will infinitely increase, like comments and things like that, there could be any number of comments so how is it all handled in php / mysql? I searched on google but i didn't really know what to search for, i typed in php comments and as you would expect php comments (as in //comment and /*comment*/ ) came up.

Is This A Good Question/Topic? 0
  • +

Replies To: Comments/ other things that could be added to infanately

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Comments/ other things that could be added to infanately

Posted 12 September 2011 - 08:47 AM

I'm not sure what you mean? In MySql you would store the comments in a table. You can add rows indefinitely to that.

As for displaying, you would use some kind of loop logic to repeat a pattern.
Was This Post Helpful? 1
  • +
  • -

#3 PixelBit  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 233
  • Joined: 17-July 11

Re: Comments/ other things that could be added to infanately

Posted 12 September 2011 - 08:55 AM

View PostCurtis Rutland, on 12 September 2011 - 08:47 AM, said:

I'm not sure what you mean? In MySql you would store the comments in a table. You can add rows indefinitely to that.

As for displaying, you would use some kind of loop logic to repeat a pattern.

But that would mean i'd have to make a whole new database per Job and then inside that create a table for comments? I wa thinking of having one table per Job rather than having so many databases.

And i see yeh a loop would work I guess, just print out each comment stored in the database, I should have thought of that myself, I probably would have if I planned on using a table exclusively for comments

This post has been edited by PixelBit: 12 September 2011 - 08:56 AM

Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4577
  • View blog
  • Posts: 8,019
  • Joined: 08-June 10

Re: Comments/ other things that could be added to infanately

Posted 12 September 2011 - 09:05 AM

Quote

But that would mean i'd have to make a whole new database per Job and then inside that create a table for comments? I wa thinking of having one table per Job rather than having so many databases.


Whole new database? No, just a table. You need to learn a bit about database normalization. You'd just need one single table for your comments, and one for whatever entity the comments are attached to. Let's use a blog for example. You might have one table like this:

BlogEntries
ID | Title | Text
---+-------+--------
1  |Title1 | Foo
---+-------+--------
2  |Title2 | Bar
--------------------


Comments
ID | BlogEntryId | CommentText
---+-------------+-------------
1  |1            | Foo
---+-------------+-------------
2  |1            | Bar
---+-------------+-------------
3  |2            | Baz
-------------------------------


In this case, you only have one table for comments, but you can see that two of the comments are for the post #1, and one of them is for post #2.

Sorry if I've misunderstood your questions and dumped a lot of beginner info on you.
Was This Post Helpful? 1
  • +
  • -

#5 PixelBit  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 233
  • Joined: 17-July 11

Re: Comments/ other things that could be added to infanately

Posted 12 September 2011 - 09:14 AM

View PostCurtis Rutland, on 12 September 2011 - 09:05 AM, said:

Quote

But that would mean i'd have to make a whole new database per Job and then inside that create a table for comments? I wa thinking of having one table per Job rather than having so many databases.


Whole new database? No, just a table. You need to learn a bit about database normalization. You'd just need one single table for your comments, and one for whatever entity the comments are attached to. Let's use a blog for example. You might have one table like this:

BlogEntries
ID | Title | Text
---+-------+--------
1  |Title1 | Foo
---+-------+--------
2  |Title2 | Bar
--------------------


Comments
ID | BlogEntryId | CommentText
---+-------------+-------------
1  |1            | Foo
---+-------------+-------------
2  |1            | Bar
---+-------------+-------------
3  |2            | Baz
-------------------------------


In this case, you only have one table for comments, but you can see that two of the comments are for the post #1, and one of them is for post #2.

Sorry if I've misunderstood your questions and dumped a lot of beginner info on you.


Well i am a beginner :P Actually this is exactly the info i needed, thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1