|
|
|
| Title : |
Creates an ID that is some what sequential but still is "a little" difficult to guess, but also is descriptive to the system.
|
| Categories : |
PHP, MySQL |
 Michael Stearne |
| Date : |
Dec 27th 1999 |
| Grade : |
5 of 5 (graded 1 times) |
| Viewed : |
3543 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Michael Stearne |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
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 | | | Convert MYSQL timestamp (14) fields back to UNIX epoch (seconds) format for display with the date() function. "revertTimeStamp($timestamp)" Categories : PHP, Date Time, MySQL | | | Output database records in multiple table columns.
multiple, table, columns, output, format, query output, html table, php Categories : General SQL, Algorithms, PHP, MySQL | | | MyOrgBook - Online Organizer written in PHP & MySql. Includes online contacts, todo, calendar, update, delete, insert, multi-user interface. Categories : PHP, MySQL, Calendar, PDAs and Organizers, Databases | | | Simple usersOnline class - keep track of how many users are online on your site Categories : PHP, PHP Classes, Databases, MySQL | | | Function to check connection to MySQL and redirect to an error page if an error occurs Categories : MySQL, PHP, Debugging, Databases | | | MySQL Web Interface Categories : MySQL, Databases, PHP | | | A PHP useradmin for MySQL. Uploading is easy. The only thing you need is
PHP and MySQL installed! Categories : MySQL, Databases, PHP, HTML and PHP | | | PostGreSQL and MySQL 2 in 1 db Manager Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL | | | AJAX Data Grid System using php and mysql. A complete login system with the ability to display data in a grid using ajax. Add , update and delete the records without reloading the page. Categories : PHP, AJAX, Databases, MySQL, Java Script | | | PHP mySQL learning example This is a complete program to modify tables
in a mySQL database on a nice and neat way. Categories : PHP, MySQL, Complete Programs, HTML and PHP | | | Loading Images to/from MySQL Categories : Databases, MySQL, PHP, Graphics | | | Add Boolean Logic Functions to Database Queries Easily. A
function to write a WHERE clause dynamically to search a
database from a search form.
Categories : MySQL, PHP, Search | | | Solution to those 'tell-a-friend' type email issues Categories : PHP, Email, Databases, MySQL | | | PHP Object Example of the Perl DBI with MySQL Categories : PHP, PHP Classes, MySQL, Databases, Perl | |
| |
| | | | | 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
| |
|
|