Results 1 to 2 of 2

Thread: Creating Unique URL/mysql ID for user post

  1. #1
    bajjuri_6 Guest

    Creating Unique URL/mysql ID for user post

    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?

  2. #2
    Join Date
    Apr 2009
    Location
    The toon
    Posts
    1,225
    use a Unix time stamp

    PHP Code:
    $unixtime time();

    echo 
    $unixtime
    Unique every "time"

    Why dont you use an Auto Incrementing field as Primary Key in the database table?
    Last edited by is_numeric; 10 Nov 2010 at 08:25 AM.

Similar Threads

  1. How to post URL's on to a web page dynamically?
    By deelyght in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 15 May 2010, 12:27 AM
  2. User input that leads to unique page
    By debtless in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 27 Dec 2008, 10:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •