Hey guys I hope you can help me...in my image gallery for my site, I have it so you can upload a max of 4 images. In the image manager, you can see the images in order from 1-4, and u can change the order by using the following code
if($change_order=="up")
{
$file_order = (int) $file_order;
if($file_order > 1)
{
$query = "update photos set file_order=file_order-1 WHERE username='$username' and file_order='$file_order'";
$db->query($query);
$file_order--;
$query = "update photos set file_order=file_order+1 WHERE username='$username' and file_order='$file_order' and id!='$id'";
$db->query($query);
}
}
if($change_order=="down")
{
$file_order = (int) $file_order;
$query = "SELECT count(*) as total FROM photos WHERE username='$username'";
$db->query($query);
$db->next_record();
$total_files = (int) $db->f("total");
if($file_order < $total_files)
{
$query = "update photos set file_order=file_order+1 WHERE username='$username' and file_order='$file_order'";
$db->query($query);
$file_order++;
$query = "update photos set file_order=file_order-1 WHERE username='$username' and file_order='$file_order' and id!='$id'";
$db->query($query);
}
}
however here is my problem...if I have 4 images, and I delete say the 3rd one.....then the file order goes 1, 2, 4....how do I make it so if theres a missing number, it resets the last image to 3?? I hope you can help me...thanks.