I'm attempting to use a form post to add rows to a mySQL table. Each row has a primary I'm calling quoteID. When a new form is submitted, it should add itself as a row in the table, with a quoteID of one greater than the previous quoteID. It current looks something like this:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
include 'verify.php';
$con = mysql_connect("localhost","user","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("internal", $con);
$previousOrderID = mysql_query("SELECT * FROM sourcingQuote ORDER BY quoteID DESC LIMIT 1");
$previousOrderID = mysql_fetch_assoc($previousOrderID);
$newOrderID = $previousOrderID['ID'] + 1;
mysql_close($con);
?>
At the moment there are 4 rows in this table, with quoteID's of 1,2,3 and 4. The odd thing is, if I attempt:
<? echo $previousOrderID; ?><br>
<? echo $newOrderID; ?><br>
The output result is:
Array
1
Why isn't $newOrderID displaying 5? and the value $previousOrderID 4?
Thanks.