I'm trying to add a number to a column called ID in my database. What should happen is when there no data in the database this script will insert the first line with the ID numbered as 1 but the issue is it's not working.
I think my checking of null data is the issue can one of you help me by pointing out what should I do.
My code
<?php
/**
* @author SiNUX
* @copyright 2013
*/
include ('connect.php');
$lastId = mysql_query("SELECT ID FROM poiinfo");
$row = mysql_fetch_array($lastId);
if (is_null($row['ID'])){
$nId = $row['ID'];
$nId = 0;
$nId = $nId++;
$addId = "INSERT INTO poiinfo(`ID`) VALUES ('$nId')";
mysql_query($addId);
}else {
$lId = $row['ID'];
$lId = $lId + 0;
$lId++;
}
?>