Delete a Photo
';
// exit;
while ($ary = mysqli_fetch_assoc($getphotos)) {
while (list($key,$val) = each($ary)) {
$$key = $val;
}
$todel1 = $config['uploaddir'] . "/$photo_id.jpg";
$todel2 = $config['uploaddir'] . "/$photo_id-t.jpg";
// echo "$todel1
";
// echo "$todel2
";
// exit;
if (is_file($todel1)) {
unlink($todel1);
}
if (is_file($todel2)) {
unlink($todel2);
}
} // END while
// exit;
// Then delete them from the db
$delquery = " DELETE FROM photos WHERE photo_id = '$photo_id' ";
// echo 'delquery: '.$delquery.'
';
// exit;
$killpics = mysqli_query($dbcrent, $delquery) or trigger_error("Bad killpics: " . mysqli_error($dbcrent));
if ($killpics) {
echo "The photo has been deleted.
";
echo "";
}
} elseif ( isset($_POST['selectlisting'] ) ) { //display the delete photo form
$listing_id = $_POST['listing_id'];
$getlistinginfo = mysqli_query($dbcrent, "SELECT address, city FROM rentals
WHERE listing_id = '$listing_id' ") or trigger_error("Bad getlistinginfo: " . mysqli_error($dbcrent));
while ($row = mysqli_fetch_assoc($getlistinginfo)) {
echo "" . $row['address'] . " " . $row['city'] . "
";
}
$getphotos = mysqli_query($dbcrent, "
SELECT * FROM photos WHERE listing_id = '$listing_id'
") or trigger_error("Bad getlistinginfo: " . mysqli_error($dbcrent));
if (mysqli_num_rows($getphotos) < 1) {
echo "This listing has no photos
";
} else {
while ($ary = mysqli_fetch_assoc($getphotos)) {
while (list($key,$val) = each($ary)) {
$$key = $val;
}
?>
Select listing:";
?>