PHP - Something like $_GET ?

8 replies
If i have some content. I want to be able to grab a section and use it as an ID

Example:

Headlines..

John Smiths email course
Tony Brown computer expert
Join Micheals forum

I want to be able to capture the names to enter into a link.

So is there some sort of bracket I can put around a certain section that i want to get?

So when they click through I can grab the name and display it on the next page without making unique pages for each name.



example url www.test.com?name=Tony Brown

then on the next page i inset the tag or something and It would bring up

You Click on Tony Brown



I hope all that makes sense.

Matthew
#$get #php
  • Profile picture of the author zerofill
    yeah you use: $_GET['name']

    If you wanted to do it you could do....

    echo "You Clicked on " . $_GET['name'];
    Signature
    Serp Shaker
    The IM World Will Be Shaken to the Core!
    Join my list at: IMCool.Biz
    New Podcast --> podcast.imcool.biz
    {{ DiscussionBoard.errors[93489].message }}
  • Profile picture of the author Matthew Miele
    I understand that. But how to i make it know to "get" the name

    As for a url

    it would be http://www.test.com?id=abc

    then $_GET['id']

    but how do I do it NOT in the url. Just a piece of text on the page.
    {{ DiscussionBoard.errors[93538].message }}
    • Profile picture of the author zerofill
      I don't understand what you mean...

      how do I make it know to "get" the name
      the things you have appended to the URL are a query string...

      so you could have

      ?name=blah&title=blahblah&lastname=blahblahblah

      $_GET['name']
      $_GET['title']
      $_GET['lastname']

      I don't understand what you mean by:
      but how do I do it NOT in the url. Just a piece of text on the page.
      $foo = $_GET['id'];

      echo $foo;

      ????

      Or POST the values...so they aren't in the URL and you can just do

      $_POST['name'];


      After posting it from a form in a text field?

      Sorry...but I don't fully understand what you are trying to accomplish. YOu will have to try and explain it better for me.
      Signature
      Serp Shaker
      The IM World Will Be Shaken to the Core!
      Join my list at: IMCool.Biz
      New Podcast --> podcast.imcool.biz
      {{ DiscussionBoard.errors[93667].message }}
  • Profile picture of the author Matthew Miele
    ok, i understand the url string etc.

    But what im trying to do is this.


    I have my webpage.

    and have my content.

    and a title for the content. like an article.


    so

    How to make a computer

    blah blah blahblah blah blahblah blah blah
    blah blah blahblah blah blahblah blah blah

    Just like in html you would but the title in <h1> tags etc.

    Is there a way I can specifie the text I want to capture (using tags? < >) just like you specifie to capture the text in the url ?id=abc

    I hope that makes sense.
    {{ DiscussionBoard.errors[93680].message }}
    • Profile picture of the author zerofill
      Your trying to get text that is already on a page and display it in another area of the page?

      Like say I have an article:

      Dog Training

      Training a dog is blah blah
      And you want to display Dog Training somewhere else on the page as well?

      Or you want to display this on another page with PHP referencing the page that has Dog Training on it?

      If it is the same page I would say hold the title of the article in a variable so you can just echo the variable out anywhere...

      If your trying to get it from another page you will have to parse that information out.

      Then again I may still not fully understand what you are trying to do...hehe...
      Signature
      Serp Shaker
      The IM World Will Be Shaken to the Core!
      Join my list at: IMCool.Biz
      New Podcast --> podcast.imcool.biz
      {{ DiscussionBoard.errors[93707].message }}
  • Profile picture of the author Matthew Miele
    haha yep youve got it!

    Basicall im trying to do both of what you said.

    Id copy the title or part of the title i need to a hyperlink : ?name=dogtraining

    then on the next page i was going to use $name = $_GET["name"];

    then use $name to display it on the page.

    Does that all sound ok?

    If so could you tell me how to the copying to the hyperlink / different place bit please hehe

    Thanks
    {{ DiscussionBoard.errors[93741].message }}
    • Profile picture of the author zerofill
      Ahh...then yeah just store the title name in a variable...

      like $foo = "MY title"

      Use that to display the title...for the article and for the hyperlink. That way you can use the same variable over and over.

      So you can make a hyperlink from the article using the variable...

      If the articles are being pulled from a MySQL database...then you are all set anyway...you can just use what is already there like $row['title']

      instead of storing it in another variable...

      Am I making sense? heh
      Signature
      Serp Shaker
      The IM World Will Be Shaken to the Core!
      Join my list at: IMCool.Biz
      New Podcast --> podcast.imcool.biz
      {{ DiscussionBoard.errors[93809].message }}
  • Profile picture of the author kidino
    Yeah, like what Donald said, use a variable. Define it in a PHP file and use the include() to call that variable file in web pages you want to use them.

    <? include('generalvar.php'); ?>

    Is this what you are looking for?
    Signature

    DIPPEC - PHP Script for Selling Digital Products with Paypal. No more monthly SaaS fees. No more commission fees. Keep it all for yourself (except for Paypal fees).

    Free Pricing Table Builder

    {{ DiscussionBoard.errors[101086].message }}

Trending Topics