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, 2022 in PHP by Kichu
• 19,050 points
275 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, 2022 in PHP by narikkadan
• 63,420 points
953 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,880 points
2,757 views
0 votes
0 answers

How to display image from database using PHP?

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

May 11, 2022 in PHP by Kichu
• 19,050 points
540 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, 2022 in PHP by Kichu
• 19,050 points
3,286 views
0 votes
0 answers

How to upload images into MySQL database using PHP code

I'm attempting to save photos from an ...READ MORE

Aug 3, 2022 in PHP by Kithuzzz
• 38,010 points
1,288 views
0 votes
0 answers

PHP using extract() to pass array values as variables and display it on a page

In order to include a specific file ...READ MORE

Aug 6, 2022 in PHP by Kithuzzz
• 38,010 points
1,085 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, 2022 in PHP by Kithuzzz
• 38,010 points
741 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, 2022 in Web Development by rajatha
• 7,640 points
22,172 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
9,670 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP