the easiest way to make a unique ID is like this
CREATE TABLE IF NOT EXISTS example (
ID BIGINT NOT NULL auto_number,
Field1 VARCHAR(100) NOT NULL,
PRIMARY KEY (ID)
)
then what you do is on an insert just pretend the field doesn't exist like so
INSERT INTO example (Field1) VALUES ('I'm a deeter head')
Then when you need to pass the ID around in forms and query strings do this
<?php
$eID = md5($ID);
$PHP_SELF?ID=$eID;
?>
When you need to decrypt the ID, it is possible even though md5 is a one way encryption cause watch:
<?php
function un_md5($table,$field,$value) {
$sql = "SELECT " . $field . " FROM " . $table . " WHERE MD5(" . $field . ")=\"" . $value . \"";
$result = @mysql_query($sql);
if(mysql_num_rows($result) < 1) {return 0;} //end if
return mysql_result($result,0,0);
?>
To recap:
Step 1) Create an auto_increment field and either primary or unique it.
Step 2) Obfuscate the ID for passing with the md5() function.
Step 3) copy and paste the above function into your script
Step 4) curse at me for not testing my script and just typing it into the message board
Step 5) fix my script
Step 6) never worry about this again and just use the script that you have placed into your global library.