Jump to content

Php and links


kan29

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.