弄清楚如何用php和mysql做到这一点

I have a variety of fields. id | lat1 | lon1 | lat2 | lon2 |

I need a way to check if data on lat1 is null, and if is null then put data in it. I was trying this:

$selec2 = "SELECT lat1 FROM usuarios WHERE androidid='$Id'";
$checklat = mysql_query($selec2, $link);

if (is_resource($checklat) and mysql_num_rows($checklat) = 0){
        $row = mysql_fetch_array($checklat);
}
else if (is_null($row)){ 
        $queif5 = mysql_query($updatelat, $link) or die(mysql_error());
        }

Thanks in advance.

You could try it in MYSQL using IFNULL like:

SELECT IFNULL(lat1, 'default') FROM usuarios WHERE androidid='$Id'

A side note, you should be using prepared statement to avoid SQL vulnerability.