kan29 Posted February 24, 2008 Share Posted February 24, 2008 Hi, I am very new to php, and working on a personal project to learn it at the moment, i am having trouble with links and php. Here is what i want to do, I have an image map, which is set up and working, now i got a mysql database too, what i want to do is when you click on a particular area, i want it to generate the results from the database using a query, where the name of the clicked area will be used in the query, question is how do i pass the value of the name to php. i know how to do that in a form, but can you do this for <a> tags or anything else. any help will be appriciated. thank you. kan Link to comment https://forums.phpfreaks.com/topic/92748-php-and-links/ Share on other sites More sharing options...
AndyB Posted February 24, 2008 Share Posted February 24, 2008 <a href="whatever.php?name=wombat">wombats</a> and then in whatever.php <?php $name = $_GET['name']; // sets $name = wombat in the example ?> Link to comment https://forums.phpfreaks.com/topic/92748-php-and-links/#findComment-475178 Share on other sites More sharing options...
thebadbad Posted February 24, 2008 Share Posted February 24, 2008 An area of your image map should link to something like query.php?name=downtown, and then your script would look like this: query.php <?php // check if the name exists/is allowed (important when used in a MySQL query. Else use mysql_real_escape_string) if (in_array($_GET['name'], array('downtown', 'center'))) { // use the name stored in $_GET['name'] for your query } else { echo 'This area does not exist!'; } ?> Link to comment https://forums.phpfreaks.com/topic/92748-php-and-links/#findComment-475185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.