|
|
|
Creates an ID that is some what sequential but still is "a little" difficult to guess, but also is
descriptive to the system.
-------------------------------------------------------------------
function genID($prefix="",$type="",$table){
global $CS_DATABASE; // Remember to define this outside the function
//// Generated an ID for various uses
srand((double)microtime()*1000000);
$ID=strtoupper($prefix).$type.date("U").sprintf("%03d",rand(0,999));
$testID=mysql_db_query($CS_DATABASE,"select ID from $table where ID='$ID'");
while(@mysql_num_Rows($testID)>0){
//print "DUPLICATE ID $ID <BR>";
$ID=strtoupper($prefix).$type.date("U").sprintf("%03d",rand(0,999));
mysql_free_result($testID);
$testID=mysql_db_query($CS_DATABASE,"select ID from $table where ID='$ID'");
}
mysql_free_result($testID);
return $ID;
}
-------------------------------------------------------------------
Usage:
$InvoiceID=genID("ABC","I","invoice");
ID is like ABCI946349503743 and can create about 50 IDs/sec before running into duplicates.
|
|
| bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Retrieve text from table and email to your e-
address in pipe delimited format. Categories : PHP, MySQL | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL | | | email new items in db Categories : PHP, Email, Databases, MySQL, Beginner Guides | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | color codes for positive and negative numbers Categories : PHP, MySQL, Databases, HTML | | | Authorize Me! An authentication script. Categories : MySQL, Databases, Authentication, PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Linked comboboxes with php-mysql & javascript Categories : PHP, Java Script, Databases, MySQL | | | mysql_escape_string Categories : PHP, MySQL, Databases, Strings | |
| | | | Ahamed Kaize wrote :667
I have a mysql filel with customer and intem information, based on this I want to develope a php script to create webbased invoices.
Who can help me?
Thanks
| |
|
|
|