Edit PHP query code depending on image map clicked area using AJAX

0 votes

I am working on an image map functionality that when you click on a specific area in the map specific MySQL commands get executed. 

The image map:

<img id="harta" src="img/hartap.png" alt="testmap" usemap="#Map" />
<map name="Map" id="Map">
    <area class="area1" alt="area1" title="area1" href="#table" shape="poly" coords="898,3071,902,3553,1108,3561,1129,3419,1254,3419,1278,3273,1472,3261,1476,3100" />
    <area class="area2" alt="area2" title="area2" href="#table" shape="poly" coords="842,2759,846,3035,1896,3076,1917,2816,1345,2774" />
    <area class="area3" alt="area3" title="area3" href="#table" shape="poly" coords="942,2327,934,2752,1342,2764,1380,2333" />
</map>

 The section with PHP code:

<section id="table" class="row">
<?php

    require_once('config.php');

      $reg = "theclickedarea"; // THIS VARIABLE HAS TO BE MODIFIED DEPENDING ON THE CLICKED AREA

      $con = mysql_connect("$host", "$username", "$password") or die(mysql_error());
      $db = mysql_select_db("$db_name") or die(mysql_error());
      $sql=mysql_query("SELECT name, score FROM table WHERE game='".$reg."'") or die(mysql_error());
      $count=0;

    echo  '<table>
                <thead>
                  <tr>
                    <th>name</th>
                    <th>score</th>
                  </tr>
                </thead>
                <tbody>';
    while($row = mysql_fetch_array($sql))
    {
       $name=$row['name'];
       $score=$row['score'];

       echo 
           '<tr>
               <td>'.$name.'</td>
               <td>'.$score.'</td>
           </tr>';

       $count++;   
    }
    echo ' </tbody> </table>  ';

?>
</section>

Can someone help me do this?

Jun 3 in PHP by Kichu
• 19,040 points
10 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
0 answers

How can i send an image map area id to a php file?

This is my image map: <map name="frozen"> ...READ MORE

Jun 16 in PHP by narikkadan
• 10,840 points
12 views
0 votes
1 answer

How to convert PHP code to MySQL query to CSV?

Hello @kartik, Try this: SELECT * INTO OUTFILE "c:/mydata.csv" FIELDS ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,720 points
992 views
0 votes
0 answers

How to display image from database using PHP?

I want to display an image from ...READ MORE

May 11 in PHP by Kichu
• 19,040 points
15 views
0 votes
0 answers

Send mail using an email account created on Hostinger (PHP)

I am using an email I created ...READ MORE

Jun 7 in PHP by Kichu
• 19,040 points
42 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,720 points
388 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,720 points
1,230 views
0 votes
0 answers

Using Jquery Ajax to retrieve data from Mysql

list.php: A simple ajax code that I ...READ MORE

Jun 20 in PHP by Kithuzzz
• 320 points
9 views
0 votes
1 answer

Using Jquery Ajax to retrieve data from Mysql

Perform a AJAX GET request to get ...READ MORE

answered Jun 23 in Web Development by rajatha
• 4,940 points
9 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
4,483 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP