$zero=0; switch ($serial) { case 'na': $querycms = "SELECT * FROM cmserial"; $resultcms= mssql_query($querycms, $link); $num_itemscm = mssql_num_rows($resultcms); //$serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm);} echo strlen($num_itemscm); echo $num_itemscm; switch (strlen($num_itemscm)) { case '1': if ($num_itemscm==9) { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);} else { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);} break; case '2': if ($num_itemscm==99) { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);} else { $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);} break; } break; case '': $serial = '(not entered)'; break; }

i'm trying to make the numbers look like 0000000001 rather than just 1, for serial purposes. so the serials look like this CM-0000000001. total 10 digits.

now as you know when it incrases from 9 to 10, i need to decrease a zero from the code so i used case for all lengths.

my problem is for example when we have 9 numbers in the db, it counts them and sees tat it will increase to 10 for the next lvl but instead of decreasing zeros by 1 and increasing 9 by 1 to 10 and concatting all; it simply does not run the code where

"if ($num_itemscm==9)

{ $serial=('CM-'.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$zero.$num_itemscm++);}"

and directypasses to the else section and does that.

any ideas appriciated? thanks