Jump to content

Archived

This topic is now archived and is closed to further replies.

dagnasty

MySQL question.

Recommended Posts

If I have a comment system for each so and so piece of content on my site, and the comments are in a seperate table. If the comment table is set up like :


Comment Table:

pagenumber      user          comment                              commentnumber
34                john          Hey, I like to post comments!    305 (auto increment)


and to get the comments for the page:

select * where pagenumber = '$pagenumber'

Would this be the best method for getting the comments if I expect the comments to get into the hundred-thousands?

I really can't think of any other way.

Share this post


Link to post
Share on other sites
How many comments do you want to see per user? Do you want to see the last ten?
SELECT top 10,* from (table)
WHERE blah blah

What exactly do you want to see?

Share this post


Link to post
Share on other sites
comments are going to be paginated on each page, but I'm asking if that's the method people use? The most efficient way?

Share this post


Link to post
Share on other sites
That is the method I use on one of my sites, [url=http://www.scriptcrawler.net]http://www.scriptcrawler.net[/url].  If you were looking at all the scripts starting with "a" for example, I select them all, then cycle through them picking out the appropriate ones for each page. I compute the first and last item to pull for each page then display it.

My way is a tad complicated though, and I'm not sure if there's a better way.

Share this post


Link to post
Share on other sites
Alright cool, thanks a lot.

Why don't you set the first letter of the script title as "startswith" in the database at the posting of the script into database, then do

select * where startswith = '$letter' SORT BY title

Share this post


Link to post
Share on other sites
use LIMIT
[code]SELECT * FROM table LIMIT 0,10[/code]
Show 10 records, starting from row 0.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.