max_cb; } elseif ($pmb_num_carte_auto_array[0] == "2" ) { $long_prefixe = $pmb_num_carte_auto_array[1]; $nb_chiffres = $pmb_num_carte_auto_array[2]; $prefix = $pmb_num_carte_auto_array[3]; $rqt = "SELECT CAST(SUBSTRING(empr_cb,".($long_prefixe+1).") AS UNSIGNED) AS max_cb, SUBSTRING(empr_cb,1,".($long_prefixe*1).") AS prefixdb FROM empr ORDER BY max_cb DESC limit 0,1" ; // modif f cerovetti pour sortir dernier code barre tri par ASCII $res = mysql_query($rqt, $dbh); $cb_initial = mysql_fetch_object($res); $cb_a_creer = ($cb_initial->max_cb*1)+1; if (!$nb_chiffres) $nb_chiffres=strlen($cb_a_creer); if (!$prefix) $prefix = $cb_initial->prefixdb; $cb_a_creer = $prefix.substr((string)str_pad($cb_a_creer, $nb_chiffres, "0", STR_PAD_LEFT),-$nb_chiffres); } get_cb($msg[42], "", $msg[43], './circ.php?categ=empr_saisie', 1, (string)$cb_a_creer, 1);