Jump to content

Trouble with some SQL in my script.


sixteh

Recommended Posts

I want to count the number of comments (stored in a database) where cid = x and sid = y then label each of the comments with their ID # relative to that set. For instance, if I have 5 comments where cid = 1 and sid = 1, with the following id's: 1, 3, 6, 7, and 9. When I display each comment, however, I want it to show the comment #. With my current code (it just displays the comment id), Comment id #1 will show 1, #3 will show #3, etc. Instead, I want it to show comment #1 as #1, but #3 as #2, its relative position among the group. However, I'm getting a syntax error with the first problem (probably just some retardation on my part):

SELECT * COUNT(id) FROM comments WHERE cid=1 AND sid=1

 

In addition, I was considering adding a rating script to rate each on a scale of 1 to 5. I already have the actual rating implemented, but I'd prefer to use something more secure for rating than cookies since a user can just clear their cookies to vote again. Is there any efficient way to label each user's account with which id's they've voted for? I'm building my website around the MyBB database.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/89938-trouble-with-some-sql-in-my-script/
Share on other sites

Archived

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

×
×
  • Create New...

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.