How could I use GeoIP in a hyperlink?

PandaJam

Don't question it.
Mar 20, 2010
132
1
0
I'm sure it's really simple. I'd like to use the free Maxmind database or similar to get the city name to put in part of the URL for a hyperlink in the page.

I know PHP but it's the actual GeoIP bit I am unsure of. Could anybody that has done this hit me up?

Thanks!
 


Code:
<script type="text/javascript">document.write('<a href="[U]http://example.com/?city=[/U]"' + escape(geoip_city()) + '">link</a>');</script>
 
Last edited by a moderator:
Code:
<script type="text/javascript">document.write('<a href="[U]http://example.com/?city=[/U]"' + escape(geoip_city()) + '">link</a>');</script>

Sorry for being an idiot, but how does this make use of a GeoIP database? I'm not too sure how it will actually input the city name into the URL string.
 
Dude! My mistake, I've only viewed this page on my iPhone and so couldn't see all the code!

Thank you so much :)
 
Right...I still can't get this to work.

I just need the city name to be found and put into an Accuweather URL, like this:

Code:
http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2ex.asp?partner=netweather&tStyle=whteYell&logo=1&zipcode=EUR|UK|UK001|*CITY GOES HERE*|&lang=uke&size=9&theme=black&metric=1&target=_self
Any ideas? Thanks!
 
In the <head>:

Code:
<script type="text/javascript" src="[URL]http://j.maxmind.com/app/geoip.js[/URL]"></script>
In the <body>:

Code:
<script type="text/javascript">document.write('<a href="[URL]http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2ex.asp?partner=netweather&tStyle=whteYell&logo=1&zipcode=EUR[/URL]|UK|UK001|"' + escape(geoip_city()) + '"|&lang=uke&size=9&theme=black&metric=1&target=_self>link</a>');</script>