Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random numbers vs sequential numbers

Status
Not open for further replies.

skydivelouie

Programmer
Jan 19, 2005
5
US
I need an expert who can help me out with a precise answer...I can't seem to find an answer on the net or in other forums...Please Help...

This is what I'm trying to accomplish...

$Alpha = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
$a = rand(0,25);
$b = rand(0,25);
$c = $Alpha[$a];
$d = $Alpha[$b];
$e = rand(10000,99999);
$f = rand(100,999);
$ID = $c.$e.$d.$f;

This produces a random ID alpha/numeric...

What I'm wanting to do is have it solely numeric and sequential...for example starting from 100 and leading up to 1000 in increments of 1...

I can find all kinds of information about producing random numbers...which I've done successfully by accident and on purpose...

It would seem that something like this would work...but it doesn't...

$a = 100; $a++
$ID = $a;

This only seems to return the ID 101 over and over...it doesn't not increase in increments of 1 with each form submission...I would like the number to be unique and non-repeptitive...

Does anyone know how this can be done?...I am at my wits end...

Any help, advice or a point in the right direction will be extremely helpful...
 
Here's a copy of the flat file funtion of the scripts:

if ($Action == "F" or $Action == "EF" or $Action == "DF"){

while (list ($key, $val) = each ($_FILE))
{
if ($key != "Settings" and $key != "Refresh")
{
$val = stripslashes($val);
$val = str_replace('"','"',$val);
$val = strip_tags($val);
$key = ucfirst($key);
$key = str_replace("_"," ",$key);
$FileData .= "$key: $val\r\n";
}
}

$FileData .= "Received: " . $Time . "\r\nIP: " . $IPAddress . "\r\n" . $FileData . "\r\n========================================\r\n\r\n";

$handle = @fopen($FlatFile,'a');
@flock($handle,LOCK_EX);
@fwrite($handle,$FileData);
@flock($handle,LOCK_UN);
@fclose($handle);

} // END OF ACTION

There is also a second settings.php file for easy manipulation, although not so easy for me. This is what I've done with that portion.

# FLAT-FILE SETTING
$FlatFile = "/mmex/ID.txt"

Also, I CHMOD to 666 for this file.

I am using this script as a form processor. I am attempting to generate a unique Order ID for each form submission. The form is sent in HTML to a specified email address with the Subject line being: Web Order - 1000. A second form submission would be sent to the same email address, although this time the subject line would be: Web Order - 1001. And so on.

I don't need to do anything with the number sequence, other than be certain that the numbers do not duplicate.

These will be in my inbox and I would access these form submissions from there.

I apologize for my ignorance and appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top