Edit a Property
";
//exit;
$rent_note = mysqli_real_escape_string($dbcrent,trim($_POST['rent_note']));
$address = mysqli_real_escape_string($dbcrent,trim($_POST['address']));
$city = mysqli_real_escape_string($dbcrent,trim($_POST['city']));
$state = mysqli_real_escape_string($dbcrent,trim($_POST['state']));
$zip = mysqli_real_escape_string($dbcrent,trim($_POST['zip']));
$beds = mysqli_real_escape_string($dbcrent,trim($_POST['beds']));
$beds = preg_replace ( "/[^0-9]/", "", $beds);
if (empty($beds)) {
$beds = "NULL";
}
$baths = mysqli_real_escape_string($dbcrent,trim($_POST['baths']));
$baths = preg_replace ( "/[^0-9]/", "", $baths);
if (empty($baths)) {
$baths = "NULL";
}
$half_baths = mysqli_real_escape_string($dbcrent,trim($_POST['half_baths']));
$half_baths = preg_replace ( "/[^0-9]/", "", $half_baths);
if (empty($half_baths)) {
$half_baths = "NULL";
}
$latitude = mysqli_real_escape_string($dbcrent,trim($_POST['latitude']));
if (empty($latitude)) {
$latitude = "NULL";
}
$longitude = mysqli_real_escape_string($dbcrent,trim($_POST['longitude']));
if (empty($longitude)) {
$longitude = "NULL";
}
$prop_desc = mysqli_real_escape_string($dbcrent,trim($_POST['prop_desc']));
$update = "UPDATE rentals SET
rental_type = '$rental_type',
rental_rate = '$rental_rate',
rent_note = '$rent_note',
address = '$address',
city = '$city',
state = '$state',
zip = '$zip',
beds = $beds,
baths = $baths,
half_baths = $half_baths,
latitude = $latitude,
longitude = $longitude,
prop_desc = '$prop_desc'
WHERE listing_id = $listing_id ";
// echo "query:
".$update;
//exit;
// $to = 'suncoast@tropworks.com';
// $subj = 'mulligan edit rental query';
// $msg = $update;
// mail($to, $subj, $msg);
$result = mysqli_query($dbcrent,$update) or trigger_error("Bad update: " . mysqli_error($dbcrent));
if ($result) {
echo "The property has been updated.
";
echo "- Add a photo to this property
";
echo " - Edit another property
";
echo "- Back to admin
";
// unset($_POST['listingselected']);
}
} elseif ( isset($_POST['selectlisting']) ) { //display the edit listing form
$listing_id = $_POST['listing_id'];
$getlistinginfo = mysqli_query($dbcrent, " SELECT * FROM rentals WHERE listing_id = '$listing_id'
") or trigger_error("Bad getlistinginfo: " . mysqli_error($dbcrent));
while ($ary = mysqli_fetch_assoc($getlistinginfo)) {
while (list($key,$val) = each($ary)) {
$$key = $val;
}
?>
Select listing to edit:";
?>