Scan for next index
Posted: Wed Oct 20, 2004 3:49 pm
Before insert a new record, I need to get the last Key (in this case, customer number) from a Table because it isn't Autoincrement. I have do this code. My question is: is there a faster way to code this... I am sure there is a better way!
Thanks 
Code: Select all
<?php
$result = mysql_query("SELECT no_client FROM clients");
if (!$result) {
echo 'Impossible d''exécuter la requête : ' . mysql_error();
exit;
}
$i = 0;
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
foreach ($line as $col_value) {
if ($col_value > $i) {
$i = $col_value;
}
}
}
$i++;
?>