Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile how to display the title of page in that pages specific URL/link?

    Hi, I'm new to PHP and I took on the challenge to build a simple blog using PHP that is similar to wordpress.


    My question is how can I display the title of the entry in the URL of that specific entry page like for example

    www.example.com/hello-world

    or real life example would be this random site that i pulled from wordpress

    http://lesbonurse.wordpress.com/

    and when you click on each blog entry title it redirects to its own page with the title in the URL like so

    http://lesbonurse.wordpress.com/2010...r-is-possible/

    and the title of entry that i clicked on the main page is " I think the word youre looking for is possible"

    I hope you understand what i m trying to acheive, its really complicated to explain when I m new to PHP.

    My blog script consists of PHP with mysqel and i can get the blog running perfectly except when i click on the entires of my blog the URL is similar to

    /view.php?$id=246

    My goal is to change "..../view.php?$id=246" into the title of the entry for example "..../hello-world"


    Is it possible to hide "view.php?$id=246" and change it to title of entry?

    Can you please help me to solve this problem?

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    or real life example would be this random site that i pulled from wordpress

    http://lesbonurse.wordpress.com/

    and when you click on each blog entry title it redirects to its own page with the title in the URL like so

    http://lesbonurse.wordpress.com/2010...r-is-possible/

    and the title of entry that i clicked on the main page is " I think the word youre looking for is possible"

    I hope you understand what i m trying to acheive, its really complicated to explain when I m new to PHP.
    Wordpress has a permalink feature, to get friendly urls.
    My blog script consists of PHP with mysqel and i can get the blog running perfectly except when i click on the entires of my blog the URL is similar to

    /view.php?$id=246

    My goal is to change "..../view.php?$id=246" into the title of the entry for example "..../hello-world"


    Is it possible to hide "view.php?$id=246" and change it to title of entry?
    Check the results of http://www.google.co.in/search?q=apa...e+friendly+url
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    This question is about .htaccess which is what wordpress use to allow them to use SEO friendly url's

    even tho this isnt in the .htacces forum section heres the code:
    Code:
    RewriteEngine on
    RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/([a-zA-Z0-9-_]+)$ /view.php?day=$1&month=$2&year=$3&name=$4
    Lets say you have a url like
    http://www.example.com/23/03/2010/Hello-World
    In PHP:
    $_GET['day'] would equal 23
    $_GET['month'] would equal 03
    $_GET['year'] would equal 2010
    $_GET['name'] would equal Hello-World

    To call the id from the database you would need to check those in a mysql_query and then call the id from that


  •  

    Posting Permissions

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