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 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2008
    Location
    MD, USA
    Posts
    65
    Thanks
    16
    Thanked 0 Times in 0 Posts

    urlencode/decode question

    I know very little about PHP so, I'm sorry and please bear with me.

    I built a page that has a list of counties covering Maryland and Virginia. When the user clicks the city link, he's taken to a page that inserts the county name into the page. Here's the code:

    index.php:

    Code:
    <a href="city.php?city=<?php echo urlencode("Anne Arundel County"); ?>">Anne Arundel County</a>
    city.php:

    Code:
    Contact us in <?php echo urldecode($_GET['city']); ?> today!
    The result on the page being, "Contact us in Anne Arundel County today!"

    My question is, if I want to add the state name to the result page as well, how would I go about this? So that it would read:

    "Contact us in Anne Arundel County today! We're fully licensed in all Maryland counties as well!"

    Is there a way to do this, rather than having to create one template for Maryland counties, and another template for Virginia counties?

    Thanks for any help. Merry Christmas!!

  • #2
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    Couldn't you do this.
    PHP Code:
    <a href="city.php?city=<?php echo urlencode("Anne Arundel County"); ?>&state=<?php echo urlencode('Maryland'); ?>">Anne Arundel County</a>
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P

  • Users who have thanked DJCMBear for this post:

    mssteph (12-24-2010)

  • #3
    New Coder
    Join Date
    Jul 2008
    Location
    MD, USA
    Posts
    65
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by DJCMBear View Post
    Couldn't you do this.
    PHP Code:
    <a href="city.php?city=<?php echo urlencode("Anne Arundel County"); ?>&state=<?php echo urlencode('Maryland'); ?>">Anne Arundel County</a>
    Thank you.

  • #4
    Senior Coder DJCMBear's Avatar
    Join Date
    Mar 2010
    Location
    United Kindom
    Posts
    1,173
    Thanks
    14
    Thanked 136 Times in 136 Posts
    No problem, if you ever need anything else just post your question, i'll be happy to help.
    Official BinPress hand picked coder.
    For anyone worried about SQL injection go have a look at my small yet powerful script here.
    Go Pledge for Light Table, if it hit's $300,000 Python and other languages will get added.
    I am 1 of 65,608 people to get a Pebble Watch :P


  •  

    Tags for this Thread

    Posting Permissions

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