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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.