Go Back  DVD Talk Forum > General Discussions > Tech Talk
Reload this Page >

PHP/MySQL Question - random ID?

Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

PHP/MySQL Question - random ID?

Old 04-18-06, 12:02 PM
  #1  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
Likes: 0
Received 0 Likes on 0 Posts
PHP/MySQL Question - random ID?

I am working on a site and I am trying to give each database entry a random id # (5 digits long from 00000 to 99999). What would be the easiest and most efficient way to handle this?

Do I need to have a script generate a random number and then check to see if it exists in the database already, if not then assign it?

I think I have been looking at this too long and need a fresh perspective.


Thanks.
Old 04-18-06, 12:08 PM
  #2  
Senior Member
 
Join Date: Sep 2002
Posts: 916
Likes: 0
Received 0 Likes on 0 Posts
substring a guid
Old 04-18-06, 12:52 PM
  #3  
DVD Talk Platinum Edition
Thread Starter
 
Join Date: Dec 2002
Location: NJ
Posts: 3,337
Likes: 0
Received 0 Likes on 0 Posts
But, I would still need to double check that against what is in the database, correct?

I think I am just overthinking this. I don't need a random id, auto incrementing is fine.
Old 04-18-06, 12:56 PM
  #4  
Senior Member
 
Join Date: Sep 2002
Posts: 916
Likes: 0
Received 0 Likes on 0 Posts
yeah u'd need to check if it exists. like u said, if you don't really need one, just auto increment it. keep it simple

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.