Search code examples
phpsqlpoint

Get value from type point in php


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


Solution

  • Try it:

    SELECT ST_X(point), ST_Y(point) FROM ...