Jump to content

[SOLVED] FLOOR in mysql statement


aldrin151

Recommended Posts

Hi everyone...I've been trying to round of by FLOOR in mysql statement the value of AS distance below...does anyone know how to write the correct way...? Reason is that when I send a param of miles in a round number format I want it to match this value.

 

  $sSQL = "SELECT *, (ACOS((SIN(RADIANS(" .$lat."))*SIN(RADIANS(latitude))) + (COS(RADIANS(" .$lat."))*COS(RADIANS(latitude))*COS(RADIANS(longitude)-RADIANS(" .$lng. ")))) * ".$unit1.") AS distance FROM users WHERE (ACOS((SIN(RADIANS(" .$lat. "))*SIN(RADIANS(latitude))) + (COS(RADIANS(" .$lat. "))*COS(RADIANS(latitude))*COS(RADIANS(longitude)-RADIANS(" .$lng. ")))) * ".$unit1.") <= " .$miles. "";

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/123183-solved-floor-in-mysql-statement/
Share on other sites

Funny I solved my own problem....this may help someone out there :)

 

 

$sSQL = "SELECT *, FLOOR((ACOS((SIN(RADIANS(" .$lat."))*SIN(RADIANS(latitude))) + (COS(RADIANS(" .$lat."))*COS(RADIANS(latitude))*COS(RADIANS(longitude)-RADIANS(" .$lng. ")))) * ".$unit1.")) AS distance FROM users WHERE FLOOR((ACOS((SIN(RADIANS(" .$lat. "))*SIN(RADIANS(latitude))) + (COS(RADIANS(" .$lat. "))*COS(RADIANS(latitude))*COS(RADIANS(longitude)-RADIANS(" .$lng. ")))) * ".$unit1.")) <= " .$miles. "";

  $sOrder = "";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.