scusa, ma non ti è sufficiente impostare un while dove l'img assume tutti i valori contenuti nel db? :master:
Poi puoi impostare tutti gli indici che vuoi!