Selecting points within a bounding square [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Help to make a selection from the database (mysql) of the coordinates.There is a table with fields latitude/longitude.The sample should be in the form of a rectangle. Thank you! example
I tried it http://www.movable-type.co.uk/scripts/latlong-db.html, but it is necessary in the form of a predetermined size of the rectangle

If you need select the point inside a rectangle is
Assuming that your rect have thr coord ($minLat , $minLng , $maxLat, $maxLng)
You can simply select the points this way
select * from my_table
where
point_lat >= $minLat
AND point_lat <= $maxLat
AND point_lng <= $maxLng
AND point_lng >= $minLng;

Related

Get value from type point in php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a field in the database of type POINT (phpMyAdmin). I use this column to save gps coordinates.
Now I want to extract the value of latitude and longitude from database.
Can I do that without having to add other fields?
$query="SELECT * FROM risk_disposal WHERE id=$id";
$result=mysqli_query($conn,$query);
while ($row2 = mysqli_fetch_array($result))
{echo "$row2['gps']";}
Database
Try it:
SELECT ST_X(point), ST_Y(point) FROM ...

Finding most common range of numbers [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a table that holds prices, the idea behind it is to have users suggest prices they think are reasonable for a good,example; range
You can divide the price by the range size, and then use FLOOR() to get the beginning of the range:
SELECT 1500*FLOOR(price/1500) AS price_base, COUNT(*) AS count
FROM yourTable
GROUP BY price_base
ORDER BY count DESC
For example, price_base = 3000 contains all prices from 3000 to 4499, while price_base = 4500 contains all prices from 4500 to 5999.

Clark's formula - population density [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a problem:
C. Clark's model of urban population densities indicating that population density varies with distance from the center of the city according to the equation Dx=D0e-bx where Dx is the population density at distance x from the center. D0 is the density at the center, e is the base of the natural logarithms, and b is a natural logarithm measuring the rate of change of density with distance.
How can I write this formula in php language?
Thanks!
What I have tried:
Dx = D/(x/b*b);
But I thinks this is wrong.
Not sure what's the problem here, so here's how I got it and you can say what did I get wrong. Afterwards, you can edit your question :)
Hence:
// this should be given
$d0 = 1.22;
$b = 0.37;
function dx($x = 0) {
global $d0, $b;
return $d0 /exp($b*$x);
}
echo dx(6.74); // d_{6.74}

MySQL select from users where there are more matches [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to know how to choose the users that have the highest number of columns to match the columns of the logged in user.
order by sum matches conditions ex:
SELECT * FROM table where fColumn = 'name' and column2='value2' or colmun3='value3'
ORDER BY (
(column2='value2') + (column3='value3')
) DESC

Get the closest value of a column in MYSQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a table that have a CP value (numeric), for example, 28030, 28060, 27100 etc. And the user can introduce a number via PHP. I want to, having this number for example, 28050, order in MYSQL my table putting 28060 as the first position.
This is the basic of my table:
SELECT * FROM `tiendas` ORDER BY `CP`
ABS() will work. Here's a query that does the job:
SELECT
CP
FROM tiendas
ORDER BY ABS(CP- 28050) ASC

Categories