Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:46:33+00:00 2026-06-16T00:46:33+00:00

I have 2 php pages. The first php page has a function that queries

  • 0

I have 2 php pages. The first php page has a function that queries MySQL. The second php page calls the function.

The function that queries MySQL works correctly when called by the second php page:

`<?php myfunction($user_id); ?>`

However I cannot seem to get the function to NOT trigger when the second php page loads and instead trigger when the user clicks inside the rectangular coordinates of an area in a map on that second page through onclick:

 `<map id="map_id_01" name="map_name_01"><area shape="poly" id="area_id_01" class="" title="area_title_01" onclick="myfunction($user_id)" coords="360,236,696,236,696,448,360,448,360,237"/></map>` 

Not sure how best to approach this and would be grateful for any ideas.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:46:34+00:00Added an answer on June 16, 2026 at 12:46 am

    You need to use a combination of javascript and php. The user clicks on the rectangle, that triggers a javascript function that makes an ajax call to another page which then runs the php function and returns the result back to the original page and then you act upon that result in javascript, be it showing it to the user by placing it in a div or executing other functions. PHP is run server side which means as soon as the page is called by the user all of the php code is executed.

    Edit To show Code:

    <map id="map_id_01" name="map_name_01"><area shape="poly" id="area_id_01" class="" title="area_title_01" onclick="myfunction()" coords="360,236,696,236,696,448,360,448,360,237"/></map>
    <script type='text/javascript'>
        var userId = '<?php echo $user_id; ?>';
        function myFunction() {
            $.ajax({
                async: false,
                type: 'POST',
                url: 'run_function.php',
                data: 'user_id=' + userId,
                dataType: 'json',
                success: function(msg) {
                    if(msg.success) {
                       //Do whatever you want to with the return message here
                    } else {
                       alert('failed to run the php function because: ' + msg.message);
                    }
                 }
            });
        </script>
    

    Then in run_function.php…

    $user_id = $_REQUEST['user_id'];
    if($return = myfunction($user_id)) {
        $reply['success'] = true;
        $reply['message'] = $return;
    } else {
        $reply['success'] = false;
        $reply['message'] = 'Failed to run function' // whatever error message you want
    }
    echo json_encode($reply);
    

    **NOTE: this is a very simplistic example of using javascript to run php functions and acting upon their reply. you will probably need to edit this code to get the desired result. Also to run $.ajax you need to have jquery included in your html. if you do not lookup xmlhttprequest for javascript

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, i have 2 php pages.first page has some functions like Connect(),... .i want
lets say i have two pages links.html & contents.php ... first page contains only
I have a index.php page that is the main page. All pages are included
I have this jQuery code: $(document).ready(function() { $.ajax({ url: pages/+page+.php, cache: false }).done(function( html
I have a PHP/MySQL based web application that has internationalization support by way of
I have a php page that also has another php page inside it, this
I have a PHP page and I want to share some data between pages
Lets say that i have 2 pages: index.php and service.php index.php sends an http-post
I have folders and pages /admin/add/index.php, /admin/edit/index.php & /admin/view/index.php which all are requiring page
I have got two pages. example.com/php.com and example.com. I use this function to set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.