No announcement yet.

Help with an ID number system

  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with an ID number system

    I'm making a random quote system for my website.
    IT was going great for a while because nobody was putting in bad quotes. Then someone submitted a stupid one that was inapropriate and I had to deny it. So I did that and then the next time someone put in a quote, there was two quotes with the same ID number because it's using the mysql_num_rows function + 1. Say the bad quote was #14 and a good quote that I didn't get to yet was #15. First I'll delete the bad quote and accept the good quote. But next time somebody puts a quote in. there will actually be 14 rows and 14 +1 will be 15. But 15 is already taken so it will show to quotes. If the new quote is bad and I want to delete it, it will delete the good quote (The original ID number 15). So I need to know how to make a good ID # system.

  • #2
    You should designate your ID column as primary index and don't touch that column when inserting quotes. That way, MySQL will take care of the numbering issues.

    Btw: How are you using the mysql_num_rows() function for this? Don't tell me you are querying the entire table to find out how many rows it has?