User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 392,038 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,309 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser:
Views: 6836 | Replies: 4
Reply
Join Date: Sep 2004
Posts: 2
Reputation: Xeph is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Xeph Xeph is offline Offline
Newbie Poster

Need to know how to create a database that will generate a random number

  #1  
Sep 4th, 2004
I need help with the exact problem this thread is titled with. To refresh your memory: I Need to know how to create a database that will generate a random number. It's to create a registry system.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2004
Location: UK
Posts: 6
Reputation: knight42 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
knight42's Avatar
knight42 knight42 is offline Offline
Newbie Poster

Re: Need to know how to create a database that will generate a random number

  #2  
Sep 6th, 2004
You're probably going to have to do this via code, or using a random function in an INSERT statement - I'm not aware of a DB that will create a random value automatically. If you're using Access then you might be able to use some VB code to put a random number, or even a GUID, into a field when a record is inserted.

If your DB supports stored procedures then you could probably write one of those to do it.

Any reason you can't just use an auto-increment field?

J
www.knight42.org.uk
Dreamweaver | PHP | MySQL | Cinema 4D | Chocolate
Reply With Quote  
Join Date: Sep 2004
Posts: 2
Reputation: Xeph is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Xeph Xeph is offline Offline
Newbie Poster

Re: Need to know how to create a database that will generate a random number

  #3  
Sep 7th, 2004
Originally Posted by knight42
You're probably going to have to do this via code, or using a random function in an INSERT statement - I'm not aware of a DB that will create a random value automatically. If you're using Access then you might be able to use some VB code to put a random number, or even a GUID, into a field when a record is inserted.

If your DB supports stored procedures then you could probably write one of those to do it.

Any reason you can't just use an auto-increment field?

J

Because I don't even know what that means. I'm a rookie, as in, I've only been at this about three days. And now I can clarify a little bit

I need to create a form that will allow one to attach a picture, and when said person sends the form, the "whatever" will generate a "random" number. Which apparently should be a number that is in sequence with another number and only appears random (one of my friends explained it to me like that, doesn't mean I understand). Then I need a database to store said info and that will allow people to look it up when needed

I am an idiot, I freely admit that.
Reply With Quote  
Join Date: Aug 2004
Location: UK
Posts: 6
Reputation: knight42 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
knight42's Avatar
knight42 knight42 is offline Offline
Newbie Poster

Re: Need to know how to create a database that will generate a random number

  #4  
Sep 7th, 2004
Originally Posted by Xeph
Because I don't even know what that means. I'm a rookie, as in, I've only been at this about three days. And now I can clarify a little bit

I need to create a form that will allow one to attach a picture, and when said person sends the form, the "whatever" will generate a "random" number. Which apparently should be a number that is in sequence with another number and only appears random (one of my friends explained it to me like that, doesn't mean I understand). Then I need a database to store said info and that will allow people to look it up when needed

I am an idiot, I freely admit that.


I'm an idiot, too.

By the sounds of it, you just need a primary key field with a number in it - primary key means that every row of the table will - and must - have a unique value in this field. You can set the database to fill this field in automatically. If you're using Microsoft Access, then just create a field called ID whose type is Autonumber. MySQL has an auto-increment property for fields, I can't remember the syntax, but I can look it up.

Anyway, I wouldn't go messing around with random numbers unless this is really needed for some reason, a unique number field will do fine.

J
www.knight42.org.uk
Dreamweaver | PHP | MySQL | Cinema 4D | Chocolate
Reply With Quote  
Join Date: Jan 2005
Posts: 20
Reputation: scoobie is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
scoobie scoobie is offline Offline
Newbie Poster

Re: Need to know how to create a database that will generate a random number

  #5  
Jan 10th, 2005
Hi,

i am very new to Mysql and php. i was wondering if anybody can help with a problem.

i have a html form that the user enters in details and when they click submit button this information is stored in the database but i have a field called ticket number and i want it to automatically generate a ticket number. this can be either all numeric or a mixture of numbers and letters.

i have no idea how to even begin to code this. Any Suggestion / sample code would be greatly appreciated.

Thanks in advanced

scoobie.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Database Design Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Database Design Forum

All times are GMT -4. The time now is 11:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC