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 5969199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:11:47+00:00 2026-05-22T20:11:47+00:00

Is it possible in the line that begins with $sql = to use the

  • 0

Is it possible in the line that begins with $sql = to use the variables that were defined earlier in javascript?

var southWestLat = map.getBounds().getSouthWest().lat();
var southWestLng = map.getBounds().getSouthWest().lng();
var northEastLat = map.getBounds().getNorthEast().lat();
var northEastLng = map.getBounds().getNorthEast().lng();

var coordinatesMap =
<?php
    global $wpdb;
    $sql = "SELECT user_id, lat, lng FROM coordinates WHERE lat>southWestLat and lat<northEastLat and lng>southWestLng and lng<northEastLng";
    $rows = $wpdb->get_results($sql, OBJECT_K);
    ...
?>;
  • 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-05-22T20:11:48+00:00Added an answer on May 22, 2026 at 8:11 pm

    Since javascript is a client side language if is not possible to directly use them. You can however use AJAX to transfer values of those JS variables to the server. Execute your sql statement and return back the results in some JSON object for example.

    HTH 🙂

    Oki so say we have the following in JS

    var myvar1 = "HELLO WORLD 1";
    var myvar2 = "HELLO WORLD 2";
    

    Now we want to send myvar to the server via AJAX. Here is how.

    $.ajax({
       type: "POST",
       url: "some.php",
       data: ({'action' : 'action1' , 'myvar1' : myvar1 , 'myvar2' : myvar2 }),
       success: function(msg){
         alert( "Data Saved: " + msg );
       }
     });
    

    The url must be some script that will handle the ajax request. What will be echoed by that script will end up in the msg variable of the success callback.

    AJAX Handler

    To do this you will need to send an extra parameter with each AJAX request. If you look at the above example I added the action parameter. This will allow us to identify which action should be executed by the AJAX Hander.

    ajaxhandler.php

    switch($_POST["action"]) {
        case "action1":
            action1($_POST["myvar1"]);
        break;
        case "action2":
            action2($_POST["myvar2"]);
        break;
    }
    
    function action1($myvar1){
        do your action logic here
    }
    
    function action2($myvar2){
        do your action logic here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How is it possible to parse command-line arguments that are to be interpreted as
I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and
Is it possible to show line numbers in the Developer Center when editing xslt
Possible Duplicate: History of changes to a particular line of code in Subversion? Using
Is possible to insert a line break where the cursor is in Vim without
Possible Duplicate: Why did we bother with line numbers at all? I'm curious about
Is it possible to add custom command-line arguments to an Eclipse .app folder? In
Is it possible to pass command line arguments into a function from within a
Is it possible to get the current source line number in Perl? The equivalent
Is it possible to have a multi-line textbox (im using asp.net c#) where the

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.