SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Title from PHP

    Hi

    I am new to PHP and struggling with the Dynamic Title for the webpage.

    this is the webpage as an example:

    site.com/page.php?lang=php&site=comparison.i-mobilephones.co.uk&options=&hs=onesilver

    As you can see the page is about HTC One Silver Mobile Phone Deals.

    Currently my webpage title for this phone is: "onesilver Cheap Mobile Phone Deals with Free Gift."

    The php code I am using to get the title is:

    <title><?php echo $_GET["hs"];?> Cheap Mobile Phone Deals with Free Gift.</title>

    where "hs" = model number of the mobile phone.

    what I want is the full model name e.g. "HTC One Silver" in the title, not "onesilver"

    I also have a php file on the server called: "model.php" in this I have

    <?php
    $model = array(onesilver => 'HTC One silver', ot1030 => 'Alcatel OT 1030');
    ?>

    Can anyone help please?

    Thanks
    Last edited by Mittineague; Sep 3, 2013 at 11:35. Reason: simplifying example URL

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    Something like this, maybe?

    Code:
    $theModel=trim($_GET['hs']);
    $titleModel='';
    
    
    $models = array(onesilver => 'HTC One silver', ot1030 => 'Alcatel OT 1030'); 
    
    if(array_key_exists($theModel, $models)){
         $titleModel=$models[$theModel];
    }
    
    echo $titleModel;
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Force Flow.
    It works perfectly fine....

    You are a STAR!


Bookmarks

Posting Permissions

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