Jump to content

How to create an 8 digit unique and random number for each posting in php


kee2ka4

Recommended Posts

Hey peeps,

 

I wanted to create a Random and a Unique Number of 8 digits that will represent each unique advert posted by users. I have an advert_id in the database that is the primary key but I do not want to use that on the site for security reasons. So each advert_id will have a unique 8 digit number which will be stored in the table under column name Ad_num. Could anyone guide me how to do this.

 

The 8 digit number has to be unique and random and no fields in the database can have the same number.

 

Thanks,

Zub

Link to comment
Share on other sites

Thanks for your reply, The only problem with timestamp value is that it gives 10 digits but I guess I can do with that. I think if I also add the advert_id to the value it will be certain that it will give me a unique number. Can the time() function ever give the same timestamp value?

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.