libelle_pc); $cotem=""; if ($typdoc == "m") { $cotem = "MULT/"; $pcm = $cotem.$pc; } //Recherche du +grand numéro inutilisé dans la cotation $q = "select convert( if (expl_cote like ('MULT%'), substring(trim(expl_cote), length('".$pcm."')+2) , substring(trim(expl_cote), length('".$pc."')+2) ), unsigned) as numero from exemplaires where expl_cote like('%".$pc."/%') order by numero asc "; $r = pmb_mysql_query($q, $dbh); $max=0; $before_num = 0; while($cote=pmb_mysql_fetch_object($r)) { $current_num= $cote->numero; if ($current_num > $before_num+1) { $max=$before_num; break; } else { $before_num=$current_num; $max=$current_num; } } $max++; $res_cote = $value_prefix_cote.$cotem.$pc."/".$max; return $res_cote; } else { return $value_prefix_cote ; } } else { return $cote; } }