1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

URL question

Discussion in 'PHP' started by cgo85, Apr 20, 2005.

  1. #1
    Is it possible to do the following:

    Instead on manually typing the url is it possible to copy the text to make a URL, for example:


    The text on the page is Seattle

    I want to be able to make a link that will work for all cities that would look something like this:

    /q.php?sub=$sub&state=$state&city=""

    Instead of having to type in /q.php?sub=$sub&state=$state&city=Seattle

    Is it possible for php to automatically put the text in for the value for "city". I don't want to have to type in every city.
     
    cgo85, Apr 20, 2005 IP
  2. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sure you can do just about anything.... you can post a specific question and you might get a more specific answer :)
     
    exam, Apr 20, 2005 IP
  3. dchoe

    dchoe Active Member

    Messages:
    64
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #3
    if you know of every possible city you would use and had a list of them, it should be very simple and quick to write up
     
    dchoe, Apr 20, 2005 IP
  4. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #4
    yup, all you need is a clean list of the sities you want to insert.
     
    fryman, Apr 20, 2005 IP
  5. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #5
    create a file with the city list one per line, just put a comma after each city except the last.

    Read the file in via file_get_contents.
    http://us3.php.net/manual/en/function.file-get-contents.php

    put the contents in an array with explode.
    http://us3.php.net/manual/en/function.explode.php

    Then foreach through it.
    http://us3.php.net/manual/en/control-structures.foreach.php

    I did not test that, but it is the psuedo code I would start with.

    Plus ya can leave the city list public and let it, maybe, get spidered.
     
    noppid, Apr 20, 2005 IP