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

Thread: grab URL text

  1. #1
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts

    grab URL text

    Okay this one thing I am trying to do, example


    http://www.site.com/Moto-Games.html

    On the page, i need to it grab "Moto" as $title = 'Moto';
    (leaving out the word "Games")

    So I can do something like (just as example)
    $sql_query = "SELECT * FROM games WHERE gametitle LIKE %$title%";

    I know you can use " $_SERVER["REQUEST_URI"]; " to get the URL, Now just need to build a mod to read it and define the word.

    Thanks
    Last edited by sitNsmile; 03-19-2010 at 10:44 PM.

  • #2
    Regular Coder sitNsmile's Avatar
    Join Date
    Dec 2009
    Location
    Charlotte, NC
    Posts
    358
    Thanks
    19
    Thanked 2 Times in 2 Posts
    I'll try something like this. If you got a better idea, please share.

    PHP Code:
    <? 

    $wordd 
    $_SERVER["REQUEST_URI"];
    $wordd str_replace("/"""$wordd);
    $wordd str_replace("-Games.html"""$wordd);

     
    ?>

  • #3
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Untested:

    Code:
    if (strpos($_SERVER["REQUEST_URI"], '-Games.html') !== false)
    {
        $request = basename($_SERVER["REQUEST_URI"], '-Games.html');
    }
    Last edited by MattF; 03-19-2010 at 11:00 PM.


  •  

    Posting Permissions

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