Nvm I got it to work my latitude and longitude were in the wrong entries :D

On Mon, Aug 27, 2012 at 7:12 AM, Andrew Evans <[email protected]>wrote:

> I am trying to figure out why executesql is not returning any results in
> this query.  I am using mysql, any suggestions would be greatly
> appreciated. There are no errors just an empty view
>
> *cheers
>
> Code Below
>
> *Controller*
>
> def location():
>     current_lat = request.post_vars["lat"]
>     current_lon = request.post_vars["lon"]
>     val = request.post_vars["search-distance"]
>     distance = db.executesql("SELECT *, (3959 * acos(cos(radians(%f)) *
> cos(radians(latitude)) * cos(radians(longitude) - radians(%f)) +
> sin(radians(%f)) * sin(radians(latitude)))) AS distance FROM listing HAVING
> distance < %d ORDER BY distance LIMIT 0, 20;" % (float(current_lat),
> float(current_lon), float(current_lat), int(val)))
>     return dict(distance=distance)
>
>
> *Example View*
>
> {{for query in distance:}}
>     <div class="listingItem">
>         <h2>{{=query[2]}}</h2>
>         <p>
>         {{=query[3]}}
>
>

-- 



Reply via email to