Hello, I'm looking for a solution to delete multiple images which has the SAME u_id in the database. So for example: Files: u_id 123.jpg 100 125.jpg 105 158.jpg 100 121.jpg 432 I would like to remove 123.jpg and 158.jpg since they have the same u_id (100). So far I have: $sql_img="select * from `img_tbl` where `u_id`='$_SESSION[ses_tuid]'"; $res_img=mysql_query($sql_img)or die(mysql_error()); $row_img=mysql_fetch_array($res_img); $file_path="uploadimg/midthum_".$row_img[imgefile]; unlink($file_path); $file_path="uploadimg/smallthum_".$row_img[imgefile]; unlink($file_path); $file_path="uploadimg/thumb-".$row_img[imgefile]; unlink($file_path); PHP: But all it does is remove only 1 image. But there are more images with the same u_id's. Can anyone help me out? Thanks
Try this $sql_img="select * from `img_tbl` where `u_id`='$_SESSION[ses_tuid]'"; $res_img=mysql_query($sql_img)or die(mysql_error()); while($row_img=mysql_fetch_array($res_img)) { $file_path="uploadimg/midthum_".$row_img[imgefile]; unlink($file_path); $file_path="uploadimg/smallthum_".$row_img[imgefile]; unlink($file_path); $file_path="uploadimg/thumb-".$row_img[imgefile]; unlink($file_path); } PHP: