prefix.'Stores'; $responsea = ''; $sql = "SELECT COUNT(*) FROM $table_name WHERE Latitude=0.000000 AND Longitude=0.000000"; $count = $wpdb->get_var($sql); if($count == 0) { $responsea = "Stores with empty coordinates not found"; } else { $sql = "SELECT ID, Street, City, Province, Country, PostalCode\n"; $sql .= " FROM $table_name WHERE Latitude=0.000000 AND Longitude=0.000000 ORDER BY ID LIMIT 1"; $q = $wpdb->get_results($sql); $responsea = "OKAY"; foreach($q AS $r) { $responsea .= "\n".$r->ID."|".$r->Street."|".$r->City."|".$r->Province."|".$r->Country."|".$r->PostalCode; } } echo $responsea; exit; } //Function to save the geo location for a record function saveAddress() { global $wpdb; $table_name = $wpdb->prefix.'Stores'; $wpdb->update( $table_name, array( 'Latitude' => $_POST['lat'], 'Longitude' => $_POST['long'] ), array( 'ID' => $_POST['ID'] ), array( '%f', '%f' ), array( '%d' ) ); $response = "OKAY"; echo $response; exit; } //Function to stripslashes and escape string function sanitize($data) { $data = trim($data); if (get_magic_quotes_gpc()) { $data = stripslashes($data); } $data = mysql_real_escape_string($data); return $data; } //Function for pagination function pagination($query, $per_page = 10,$page = 1, $url = '?') { global $wpdb; $table_name = $wpdb->prefix.'Stores'; $query = "SELECT COUNT(*) AS num FROM {$query}"; $total = $wpdb->get_var($query); $adjacents = "2"; $page = ($page == 0 ? 1 : $page); $start = ($page - 1) * $per_page; $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total/$per_page); $lpm1 = $lastpage - 1; $pagination = ""; if($lastpage > 1) { $pagination .= "\n"; } return $pagination; } ?>