I have a problem to update sql record by checkbox in php.My problem is when I press the update
button,all can show me update previous info record,but only in the checkbox unable to show me the previous record. Below is my coding:
Checkbox coding:
<div class="form-group col-lg-6">
<label class="control-label col-lg-4">Pricing<span style="color:red;"> </span></label>
<div class="col-lg-8">
<input type="checkbox" name="rm_option" id="rm_option" value="1"><strong> RM </strong></input>
<input type="checkbox" name="point_option" id="point_option" value="1"><strong> Full Point </strong></input>
<input type="checkbox" name="partial_option" id="partial_option" value="1"><strong> Partial Point + RM </strong></input>
</div>
</div>
update function coding:
else if($action == 'update') {
$id = isset($_POST['filter_id']) ? $_POST['filter_id'] : "";
$id_promotion_categories = isset($_POST['id_promotion_categories']) ? $_POST['id_promotion_categories'] : "";
$promotion_title = isset($_POST['promotion_title']) ? $_POST['promotion_title'] : "";
$promotion_description = isset($_POST['promotion_description']) ? $_POST['promotion_description'] : "";
$reservation = isset($_POST['reservation']) ? $_POST['reservation'] : "";
$feature = isset($_POST['feature']) ? $_POST['feature'] : "";
$discount_percentage = isset($_POST['discount_percentage']) ? $_POST['discount_percentage'] : "";
$promotion_price_before = isset($_POST['promotion_price_before']) ? $_POST['promotion_price_before'] : "";
$promotion_price_before = isset($_POST['promotion_price_before']) ? $_POST['promotion_price_before'] : "";
$rm = isset($_POST['rm']) ? $_POST['rm'] : "";
$point = isset($_POST['point']) ? $_POST['point'] : "";
$partial_point = isset($_POST['point_rm_point']) ? $_POST['point_rm_point'] : "";
$partial_rm = isset($_POST['point_rm_rm']) ? $_POST['point_rm_rm'] : "";
$rm_option = isset($_POST['rm_option ']) ? $_POST['rm_option '] : "";
$point_option = isset($_POST['point_option ']) ? $_POST['point_option '] : "";
$partial_option = isset($_POST['partial_option ']) ? $_POST['partial_option '] : "";
$query = "UPDATE " . $table ." SET id_promotion_categories = '" . $id_promotion_categories . "', promotion_title = '".$promotion_title."', promotion_description = '".$promotion_description."', reservation = '".$reservation."',rm = '".$rm."',point = '".$point."',point_rm_point = '".$partial_point."',point_rm_rm = '".$partial_rm."',rm_option = '".$rm_option."',point_option = '".$point_option."',partial_option = '".$partial_option."', feature = '".$feature."' where id='" . $id . "'";
$arr_treatment = db_conn_update($query);
if ($arr_treatment) {
$result_arr['msg'] = 'Update Successful';
} else {
$result_arr['msg'] = 'Error in processing data. Please try again later.';
}
$result_arr = special_char_display_arr($result_arr);
$json = json_encode($result_arr);
print($json);
} else if($action == 'edit'){
$id = isset($_POST['id']) ? $_POST['id'] : "";
$sql = 'SELECT * FROM promotion_list WHERE id = ' . $id;
$result_arr['sql'] = $sql;
$result_arr = get_tbl_row($sql);
//$result_arr['treatment_category_name'] = get_tbl_val('treatment_category_list', 'id', 'name', $result_arr['category']);
$result_arr = special_char_display_arr($result_arr);
$json = json_encode($result_arr);
print($json);
Below is my output, the red box and the arrow means it unable to show me the previous record to update when I press the update
button:
Hope someone can guide me how to solve it. Thanks.
Aucun commentaire:
Enregistrer un commentaire