View Single Post
Old 02-25-2008, 03:04 PM   #3 (permalink)
abiko
The Contributor
 
abiko's Avatar
 
Join Date: Feb 2008
Location: Croatia
Posts: 90
Thanks: 4
abiko is on a distinguished road
Big Grin

You can always md5() or sha1() the string combined with the time of creation.
Here is a SHA1 solution - it generates a 8 char string.
strtoupper is there if you want to have uppercase letters instead lowercase.
PHP Code:
<?php
// MD5 generates a 32-bit
// If you want to use 8bit or 
$session_id sha1(uniqid(mt_rand(), true));
$id substr$session_id08);
$id strtoupper$id );
echo 
$id;
?>
Now you have an identifier for you so you just save it in the table and you're set to go.
if you url is
Code:
http://yoursite.com/watch/C21D36C7/
Your script searches for the ident string (C21D36C7) for the item - your every item has an unique string generated with the snippet above.

So in your database table should look like this
|id | ident |....other | fields

Hope this helpes
__________________
Back from sysadmins to the programmers.
Send a message via ICQ to abiko Send a message via MSN to abiko
abiko is offline  
Reply With Quote