21 lines
606 B
PHP
21 lines
606 B
PHP
|
|
<?php
|
||
|
|
$type = substr($_REQUEST['code'], 0,2);
|
||
|
|
$type = strtoupper($type);
|
||
|
|
echo $type."<br><br>";
|
||
|
|
$db = $GLOBALS['db'];
|
||
|
|
for ($i=0; $i<10000; $i++) {
|
||
|
|
$s = (string) $i;
|
||
|
|
while (strlen($s) < 5)
|
||
|
|
$s = '0'.$s;
|
||
|
|
$res = $db->query("SELECT id FROM ecmproducts WHERE code='".$type.$s."'");
|
||
|
|
$e = '';
|
||
|
|
if ($res->num_rows==0) {
|
||
|
|
$ress = $db->query("SELECT code FROM ecmproducts WHERE code LIKE '".$type.$s."%'");
|
||
|
|
while ($rr = $db->fetchByAssoc($ress))
|
||
|
|
$e.=$rr['code'].' ';
|
||
|
|
if ($ress->num_rows>0)
|
||
|
|
$e = ' ('.$e.')';
|
||
|
|
echo $type.$s.$e.'<br>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|