Forum Moderators: coopster
I have an image upload script that loops through and assigns numbers to each image, it works perfect BUT I have added a display order to the database entry to keep them in the order I want them however, if I upload 10 images obviousley the display order now returns 1, 10, 2 as theres no zero before the single diget images, heres my code
for ($i=1;$i<11;$i++)
{
$thepic="pic".$i;
if (($$thepic<>"none") and ($$thepic<>""))
{
$dest="../folder_name/images/".$insid."-".$i.".jpg
$sql = "insert into images values('', '$insid-$i.jpg', '$insid', '$i')";
I tried adding the zero to $i=01 but it didnt do as wanted, the column for display order is a varchar if that helps.
Thanks
$name = sprintf("%s-%03d.jpg",$insid,$i);
$dest="../folder_name/images/$name";