How do I put this GET inside an echo?

Discussion in 'PHP' started by mark_s, Apr 5, 2009.

  1. #1
    I have a title tag that is defined by $title, I would like that to echo a few words but also include a GET statement for the page number. I don't know how to put them together...

    This is my failed attempt:

    <? $title = $_GET['page']; "News Archive"; ?>
     
    mark_s, Apr 5, 2009 IP
  2. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #2
    <?php echo $_GET['page'] . "News Archive"; ?>
    // OR
    <?php $title = $_GET['page']; echo $title . "News Archive"; ?>
    PHP:
     
    ActiveFrost, Apr 5, 2009 IP
  3. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your quick reply.

    Your first one leaves the title blank, your second one only shows the page number.
     
    mark_s, Apr 5, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Try the following:
    
    <?php $title = $_GET['page'] . "News archive"; echo $title; ?>
    
    PHP:
     
    PoPSiCLe, Apr 5, 2009 IP
    mark_s likes this.
  5. mark_s

    mark_s Peon

    Messages:
    497
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you, worked great :)
     
    mark_s, Apr 5, 2009 IP
  6. SiteSlangin

    SiteSlangin Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yup just make the GET a $variable then echo the $variable.
     
    SiteSlangin, Apr 5, 2009 IP