DAngelo Posted July 29, 2012 Posted July 29, 2012 I have a link that is in a table. I would like to change the destination of that link based on the users location. Is this possible? And could you give a brief example of how it could be done? Thanks! Quote
Uridium Posted July 29, 2012 Posted July 29, 2012 DAngelo do you mean so they can be viewed on viewuser or to be attacked example Quote
DAngelo Posted July 29, 2012 Author Posted July 29, 2012 (edited) They need to view a specific page when clicking on the link based on their location. Say they are in NY and they click the link they need to view a page for NY but if they are in Chicago they need to view a page for Chicago. There will be 7 different pages total. Edit. I tried using a switch but cant seem to get it to work since the link in question is inside a table on the explore page. Edited July 29, 2012 by DAngelo Quote
Uridium Posted July 29, 2012 Posted July 29, 2012 are you calling for a users location in an QUERY look at how viewuser uses the attack link to grab info then do the same for example their whereabouts but i cant see this happening as both people would need to be in the same place example both in NY and both in i donn for arguments sake Winter Ruins location.... Quote
DAngelo Posted July 29, 2012 Author Posted July 29, 2012 Its only concerns the one user clicking the link. I am setting up a mod that users have to complete certain tasks in order to unlock the next city. So when they click the link it needs to display the tasks for the city they are in. I suppose it would be easier to just put all the tasks on one page and call it but then the page would be cluttered and confusing for the user. Quote
Seker Posted July 29, 2012 Posted July 29, 2012 Basic example: if ($city == 1) { $link = "<a href='example.php?action=dosomething'>[Link Name Here]</a>"; } if ($city == 2) { $link = "<a href='example.php?action=dosomethingelse'>[Other Link Name Here]</a>"; } etc., etc. Again, very basic example, but something like that should do the trick. Then just echo/print $link inside your table. Quote
DAngelo Posted July 29, 2012 Author Posted July 29, 2012 (edited) This is kinda what I was thinking but this just gives a different explore page for each city instead of changing the link. Although this may be useful for adding mods to specific cities and not all of them. switch ({$ir['location']}): case '51': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreCHI.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; case '52': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreDAL.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; case '53': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreBOS.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; case '54': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreDET.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; case '55': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreMIA.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; case '56': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreLA.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; case '57': "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='exploreLV.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; break; default: "<tr> <td colspan='10' style='background:url(images/side_28.png) no-repeat;' width='204' height='30'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='45px'>Â </td><td><a href='explore.php'>$area->areaname</a></td></tr></table></td> <td><img src='images/spacer.gif' width='1' height='30' border='0' alt='' /></td> </tr>"; endswitch; Edited July 29, 2012 by DAngelo Quote
SilverStar Posted July 29, 2012 Posted July 29, 2012 <?php switch($location) { case "New York": $url = "URL HERE"; break; case "Los Angeles": $url = "URL HERE"; break; } Quote
Uridium Posted July 29, 2012 Posted July 29, 2012 question is everyone of them pages different other than just grabbing player data and loction ? Quote
DAngelo Posted July 29, 2012 Author Posted July 29, 2012 Yes each page is different with the exception of a few standard things that needs to be on each page. It allows me to control the rewards for users based on level and location as well as provide unique features in each city. At least that is my goal! lol Quote
KyleMassacre Posted July 30, 2012 Posted July 30, 2012 If your just changing a few of the items I would go with what seker stated, but if your changing a lot of stuff go with what silverstar showed and create a a switch. Going based of what you showed sekers idea is better so you can do something like if ($ir['location'] == 1) { $link="<a href='exploreMIA.php'>Explore</a>"; }else if { Blah blah keep on keepin on with this format Then just print $link or whatever you wish to call it where you wish to place it Quote
DAngelo Posted July 30, 2012 Author Posted July 30, 2012 Thank to everyone for the help! I did use that and it worked fine. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.