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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.