PDA

View Full Version : Creating Unique URL/mysql ID for user post



bajjuri_6
09 Nov 2010, 07:52 PM
I am trying to create a simple blog engine using PHP and mysql. I'm having trouble generating unique post ID's that I can associate with a clean URL format. I am currently using this strategy:

The URL format is: example.come/username/2010/11/09/title-title-title

then I'm using mod_rewrite to convert this format to URL parameters and then append the parameters to come up with post ID.

The problem is: if a user posts 2 blogs with the same title on the same day, this strategy fails. Can someone suggest a better strategy?

is_numeric
10 Nov 2010, 07:58 AM
use a Unix time stamp


$unixtime = time();

echo $unixtime;

Unique every "time"

Why dont you use an Auto Incrementing field as Primary Key in the database table?