Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 25th, 2004, 12:06 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default random number

I am creating random invoice number with following.

srand((double)microtime()*1000000);
$invoicenumber=rand(10000000,99999999);
echo "$invoicenumber";

 looks like so far it is doing the job, but Is this the right way..

thanks

Reply With Quote
  #2 (permalink)  
Old October 25th, 2004, 08:43 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Depends on exactly what you want to do. Do you just want a number to show the user? Or do you want a number to show the user and put in a database? All you seem to be doing is displaying it.

Also, in PHP versions later than 4.2, there is no need to call srand().

But if it is doing the job, is it not the right way for you? :-)

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
There are only two stupid questions: the one you can't find the answer to and don't ask, and the one that you can find the answer and do ask.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Number Generation i_shahid C# 2005 2 March 31st, 2008 10:50 PM
random number rajuru Beginning PHP 7 December 7th, 2004 10:52 AM
random number code rob209 SQL Server 2000 1 June 17th, 2004 04:05 PM
Random Number Blaise Access 5 August 23rd, 2003 06:48 AM



All times are GMT -4. The time now is 03:12 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.