Reputation: 3083
If you have a query like
SELECT max(customerID) FROM customers
Is there a way to save that directly to a variable instead of using
$results = $dbLink->query("SELECT max(customerID) FROM customers");
while($row = $results->fetch_assoc()){
$maxID = $row['customerID'];
}
The latter is just a lot of type for 1 value
Upvotes: 0
Views: 36
Reputation: 255025
That's easy - just don't use loop:
$results = $dbLink->query("SELECT max(customerID) FROM customers");
$row = $results->fetch_assoc();
$maxID = $row['customerID'];
Upvotes: 3