1
I ran into a problem I can’t get around. The situation is as follows, I created a search system in mysql that results in markings on the map (Google Maps API) that I created. The problem is that some of the customers have the blank"lat" and "Lon" fields, and this results in an error in the Google Maps API, which is all blank. The idea is that if any client has blank "lat" and "Lon", not echo fields on this client. This would not result in errors on the map. And the other clients with all fields filled would echo normally. I’ve tried using IS NOT NULL, but it doesn’t work. PHP code:
$sql = mysql_query("SELECT * FROM politicos WHERE name LIKE '%$busca%' OR info LIKE '%$busca%' AND lat IS NOT NULL");
while($row = mysql_fetch_array($sql)){
$name = $row['name'];
$lat = $row['lat'];
$lon = $row['lon'];
$info = $row['info'];
echo("addMarker($lat, $lon, '<b>Nome: $name</b><br />Informações: $info');\n");
}
Echo result:
addMarker(, , '<b>Nome: Cliente 1</b><br />Informações: ');
this results in error on the map
Echo result if put 0 in lat and Lon:
addMarker(0, 0, '<b>Nome: Cliente 1</b><br />Informações: ');
that puts the marker on the equator line :(
I do not want to echo into customers with the fields "lat" and "Lon" empty! If anyone can help me, I’d really appreciate it!
A ideia é que se algum cliente estiver com os campos "lat" e "lon" em branco, não de echo neste cliente.
see, empty and null are different things. The fields in bd get null values, even?– Thiago
Try adding parentheses in the conditions that involve
like
, guyWHERE (name LIKE ... OR info LIKE ...) AND lat IS NOT NULL
. Enjoy and read Why should we not use mysql type functions_*?.– Woss