Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts

    SELECT query and plot onto Google Maps

    I have some .js that allows me to connect to my sql database and plot all lat's and longs, yet the page I want it displayed is a results page from a form.

    The query I currently have in the google api script is;

    PHP Code:
    <?
     $query 
    mysql_query("SELECT * FROM `family_support` WHERE 1");
     while (
    $row mysql_fetch_array($query)){    
     
    $org_name=$row['org_name'];
     
    $lat=$row['lat'];
     
    $long=$row['long'];
     
    $org_address=$row['org_address'];
     echo (
    "addMarker($lat, $long,'<b>$org_name</b><br/>$org_address');\n");
     }
     
    ?>
    i would like this to change (as it is displaying all rows currently) to the query I have in the results page;

    PHP Code:
    $sql_result"SELECT * FROM family_support WHERE org_name LIKE '%$org_name%'";

    if (
    $area != 'All') {
    $sql_result .=" AND area LIKE '%$area%'";
    }
    if (
    $services != 'All') {
    $sql_result .=" AND services LIKE '%$services%'";
    }
    if (
    $hardiker != 'All') {
    $sql_result .=" AND hardiker = '$hardiker'";
    }

    $sql_result .=" ORDER BY org_name";
    //echo $sql_result;
    $result =  mysql_query($sql_result$dbh) or die ('Database currently being updated, please try again later!'); 
    $num=mysql_numrows($result); 
    Is this possible?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    I don't see why it wouldn't work.
    You'll just have to know if you found any results (rows).

    What are you getting for this?
    $num=mysql_numrows($result);

    If it's always 0, that means nothing is matching your query.

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    49
    Thanks
    13
    Thanked 0 Times in 0 Posts
    What I'm trying to do is to change the query in the google maps script to match that of the second query. The query in the google maps script is showing all the results of my DB, not those from a form I made that is using the 2nd...


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •