hi guys,
in need of some advise, I’m busy with a classifieds website where people list the items for sale, but under admin I have a link to delete ALL ads from a client
which must also delete the images on the server for each ad of that client. the script runs perfectly to delete all ads + the client account, but the script only deletes
the first ad’s pictures, the rest of the ads pictures remains on the server? Mayby just something small that I am missing, please help.
the code the delete the images for the ads :
$result = mysql_query("SELECT * FROM listings WHERE client_id='" . $aid . "'"); // GET CLIENT ADS
if($result) {
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // DELETE ALL PICTURES
$images = mysql_fetch_assoc($result);
$img1 = $images['photo1']; $img2 = $images['photo2'];
$img3 = $images['photo3']; $img4 = $images['photo4'];
$img5 = $images['photo5']; $timg1 = $images['thb1'];
$timg2 = $images['thb2']; $timg3 = $images['thb3'];
$timg4 = $images['thb4']; $timg5 = $images['thb5'];
if($img1 !="empty") { @unlink('../'.$img1); }
if($img2 !="empty") { @unlink('../'.$img2); }
if($img3 !="empty") { @unlink('../'.$img3); }
if($img4 !="empty") { @unlink('../'.$img4); }
if($img5 !="empty") { @unlink('../'.$img5); }
if ($timg1 != 'empty') { @unlink('../'.$timg1);}
if ($timg2 != 'empty') { @unlink('../'.$timg2);}
if ($timg3 != 'empty') { @unlink('../'.$timg3);}
if ($timg4 != 'empty') { @unlink('../'.$timg4);}
if ($timg5 != 'empty') { @unlink('../'.$timg5);}
}
}