Ciao ragazzi,
Sto incontrando un problema nella generazione di un numero progressivo che aumenta ogni volta che faccio il submit del form.
Vi spiego: fino a quando arrivo a 10 va bene, ma quando arrivo all'11 mi torna all'1.
Il numero progressivo che devo ottenere è questo:
2015.00001
Quanto diventa 10, deve diventare 2015.00010
Quando diventa 100, deve diventare 2015.00100
Però quando è 11, così com'è ora diventa 2015.00001.
Sbaglio qualcosa nel codice:
Codice PHP:
$this->sql = "SELECT codice FROM accettazione ORDER BY id DESC LIMIT 1";
if ($result = $this->hookUp->query($this->sql)) {
if ($result->num_rows > 0) {
while ($rw = mysqli_fetch_array($result, MYSQLI_BOTH)) {
$codice = substr($rw['codice'], -1);
$rw['codice'] = date("Y") . ".0000";
echo $rw["codice"] . ++$codice;
}
} else {
echo date("Y") . ".00001";
}
} else if ($this->hookUp->query($this->sql) === false) {
echo "fail";
}
Mi segnalate l'errore?
Grazie