...

View Full Version : SELECT query and plot onto Google Maps



stephen_
01-20-2012, 04:36 PM
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;



<?
$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;



$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?

mlseim
01-20-2012, 06:13 PM
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.

stephen_
01-23-2012, 08:11 PM
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...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum