ok this script works for everything except checkboxes.
<?php
$INTEGER_FIELDS = array('property_id'); // as many as you need
$insert = array();
foreach($_REQUEST as $key => $value){
//if($value == '') continue;
if($value == 'Submit') continue;
//if($value == '0') continue;
if($value == '685388') continue;
if($value == '12446606') continue;
if($value == '685388:12446606') continue;
if(in_array($key, $INTEGER_FIELDS)){
// Error checking
if(is_int($value)){
die('Error ... ['.$key.'] field does not contain an integer.');
}
//$insert[$key] = $value;
$sql_2 .= ($key.'='.$value.', ');
} else {
//$insert[$key] = "'".$value."'";
$sql_2 .= ($key."='".$value."', ");
}
}
$sql = "UPDATE listings SET $sql_2 WHERE id=$id" or die("Invalid query: " . mysql_error());
echo $sql;
?>
my checkbox field looks like this.
<input name="tiled_roof" type="checkbox" id="tiled_roof" value="1" <? if($line["tiled_roof"] == 1){echo 'checked';} ?> >
if the box is checked then i have no problems see out put.
UPDATE property SET property_id=350554, category='commercial', development='', office_area='1', stoor_room_area='2', vehicle_parks='3', vparks='covered', single_story='4', multi_story='', facilities='5', municipility='', sales_status='', price='', type='All', building_area='', land_area='', offices='', boadroom='', bathrooms='', toilets='', ensuit='', laundry_facilities='', accommodation_facilities='', additional_areas='loft', hot_water='solar_electric', tiled_roof='1', building_style='other', other_extra_features='', title='', description='', date='2005-03-14' WHERE id=35
see "tiled_roof='1'" it comes up.
but if the checkbox is unchecked it disapears
UPDATE property SET property_id=350554, category='commercial', development='', office_area='1', stoor_room_area='2', vehicle_parks='3', vparks='covered', single_story='4', multi_story='', facilities='5', municipility='', sales_status='', price='', type='All', building_area='', land_area='', offices='', boadroom='', bathrooms='', toilets='', ensuit='', laundry_facilities='', accommodation_facilities='', additional_areas='loft', hot_water='solar_electric', building_style='other', other_extra_features='', title='', description='', date='2005-03-14' WHERE id=35
i dont want it to disapear i want it to come up with a "tiled_roof='0'" or just nothing "tiled_roof=''"so the database gets updated..
please help. im desperatly running out of time now.
cheers aron.