random number

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
How can I make an application form that generates a unique number starting  
from 1001.?

Re: random number

"VAL" wrote:

Quoted text here. Click to load it

<?php echo rand() + 1001; ?>

phil [dot] ronan @ virgin [dot] net

Re: random number

VAL said the following on 12/10/2005 20:13:
Quoted text here. Click to load it

Did you even bother to read the PHP manual for random functions, e.g.  


Re: random number

from Oli Filth contained the following:

Quoted text here. Click to load it

Why bother with rand()?  Just start at 1001 and increment.  Each number
will be unique.

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Re: random number

VAL wrote:
Quoted text here. Click to load it

Your subject line says "Random number", and you are asking for a "Unique  
number". Which is it? A random number, or a number which is unique, or both?

Nicholas Sherlock

Re: random number

Nicholas Sherlock wrote:
Quoted text here. Click to load it

I interpreted this (despite the subject, which I didn't notice) as 'how  
can I arrange that every time this page is run it will generate a  
different number?'

If that is indeed the question, then you need to save the latest number  
(or all of them, if they are indeed to be random rather than sequential)  
locally on the server - either in a file or in a database.


Re: random number

Your question is contradictory mate you couldnt make a random number
that began with specified non random value. You could however make a
string variable that was comprised of both a constant value of '1001.'
and an entirely random number using a random number generating
function. Like this
$string .= '1001';
$string .= 'your random number';

echo $string;

You would need to ask someone else about generating a random number in
PHP as i've never had to do it, i just stick a few incrementing numbers
together pulled from a database if i want to create a unique value like
for a transaction ID or something.

Site Timeline