Inquiry:
$query = "SELECT MAX(orderID) as orderID
FROM orders
WHERE customerID = '" . $_SESSION['accountID'] . "'";
If customerID is a number, single quotes can be removed to make a request:
$query = "SELECT MAX(orderID) as orderID
FROM orders
WHERE customerID = " . $_SESSION['accountID'];
Then...
$result = mysqli_query($database_link, $query);
$row = $result->fetch_object();
$orderID = $row->orderID;
source
share