Re: Generating Order Number
| From: | Brian T. Allen | Date: | Thu, 19 Oct 2000 07:44:22 +0000 |
| Subject: | Re: Generating Order Number | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21109@lists.php.net to get a copy of this message | ||
Creating the order number is a piece of cake, storing the previous one is a
little more involved, but not hard.
There are a number of ways to store the info in a file and retrieve it
later.
The shortest code-wise is:
$order_number =
cat /dir/order_number.txt; // Read in the current order
number
echo $order_number; // Use the order number, echo it out, mail it, whatever
$order_number++; // Increment the order number
echo $order_number > /dir/order_number.txt; // Save the incremented order
number
Note that you would have to initially create order_number.txt with the
proper permissions and the beginning order number without a newline. This
also assumes you are on a unix OS.
There are far more complicated ways to do this which involve safety features
such as file locking, etc, but this would work on a low traffic site.
See http://www.php.net/manual/language.operators.execution.php
for an
overview of execution operators such as $results = command;
See http://www.php.net/manual/ref.filesystem.php
for an overview of handling
files.
Hope that helps,
Brian
> Hi,
>
> Anyone know how to create an Order Number without using a database (the
> client doesn`t want a database) What I have at the moment is a basic order
> page, user fills in his details selects a product and clicks submit, then
he
> is directed to a thank you page which shows him his order number and a
> telephone number. But I have no idea how to create them.
>
> Any ideas?
>
> TIA
>
> Ade
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net