由于我的最后一个问题已经解决,我的问题已经解决了一半,所以我要再问一次,当我提交表单以更新 MySQL 记录时,我遇到了语法错误,除非所有字段都已填写。我得到了一个解决方案来修复它,它允许表单在不填写所有字段的情况下更新记录,而不是传递在字段中发布的数据,所有表单帖子在数据库的所有字段中都是数字 1 . 有什么办法解决这个问题?
<?php
// Database ID //
$id=$_POST['id'];
// section 1 column 1 row 1 - 5 //
$item_qty1=(isset($_POST['item_qty1'])
$item_qty2=(isset($_POST['item_qty2'])
$item_qty3=(isset($_POST['item_qty3'])
$item_qty4=(isset($_POST['item_qty4'])
$item_qty5=(isset($_POST['item_qty5'])
// section 1 column 2 row 1 - 5 //
$manuf_1=(isset($_POST['manuf_1']) AND !empty($_POST['manuf_1'])? $_POST['manuf_1'] : '');
$manuf_2=(isset($_POST['manuf_2']) AND !empty($_POST['manuf_2'])? $_POST['manuf_2'] : '');
$manuf_3=(isset($_POST['manuf_3']) AND !empty($_POST['manuf_3'])? $_POST['manuf_3'] : '');
$manuf_4=(isset($_POST['manuf_4']) AND !empty($_POST['manuf_4'])? $_POST['manuf_4'] : '');
$manuf_5=(isset($_POST['manuf_5']) AND !empty($_POST['manuf_5'])? $_POST['manuf_5'] : '');
// section 1 column 3 row 1 - 5 //
$part_number1=(isset($_POST['part_number1']) AND !empty($_POST['part_number1'])? $_POST['part_number1'] : '');
$part_number2=(isset($_POST['part_number2']) AND !empty($_POST['part_number2'])? $_POST['part_number2'] : '');
$part_number3=(isset($_POST['part_number3']) AND !empty($_POST['part_number3'])? $_POST['part_number3'] : '');
$part_number4=(isset($_POST['part_number4']) AND !empty($_POST['part_number4'])? $_POST['part_number4'] : '');
$part_number5=(isset($_POST['part_number5']) AND !empty($_POST['part_number5'])? $_POST['part_number5'] : '');
// section 1 column 4 row 1 - 5 //
$part_description1=(isset($_POST['part_description1']) AND !empty($_POST['part_description1'])? $_POST['part_description1'] : '');
$part_description2=(isset($_POST['part_description2']) AND !empty($_POST['part_description2'])? $_POST['part_description2'] : '');
$part_description3=(isset($_POST['part_description3']) AND !empty($_POST['part_description3'])? $_POST['part_description3'] : '');
$part_description4=(isset($_POST['part_description4']) AND !empty($_POST['part_description4'])? $_POST['part_description4'] : '');
$part_description5=(isset($_POST['part_description5']) AND !empty($_POST['part_description5'])? $_POST['part_description5'] : '');
// section 1 column 5 row 1 - 5 //
$part_price1=(isset($_POST['part_price1']) AND !empty($_POST['part_price1'])? $_POST['part_price1'] : '');
$part_price2=(isset($_POST['part_price2']) AND !empty($_POST['part_price2'])? $_POST['part_price2'] : '');
$part_price3=(isset($_POST['part_price3']) AND !empty($_POST['part_price3'])? $_POST['part_price3'] : '');
$part_price4=(isset($_POST['part_price4']) AND !empty($_POST['part_price4'])? $_POST['part_price4'] : '');
$part_price5=(isset($_POST['part_price5']) AND !empty($_POST['part_price5'])? $_POST['part_price5'] : '');
// section 1 column 6 row 1 - 5 //
$price_extension1=(isset($_POST['price_extension1']) AND !empty($_POST['price_extension1'])? $_POST['price_extension1'] : '');
$price_extension2=(isset($_POST['price_extension2']) AND !empty($_POST['price_extension2'])? $_POST['price_extension2'] : '');
$price_extension3=(isset($_POST['price_extension3']) AND !empty($_POST['price_extension3'])? $_POST['price_extension3'] : '');
$price_extension4=(isset($_POST['price_extension4']) AND !empty($_POST['price_extension4'])? $_POST['price_extension4'] : '');
$price_extension5=(isset($_POST['price_extension5']) AND !empty($_POST['price_extension5'])? $_POST['price_extension5'] : '');
// end of section 1 totals //
$material_cost=$_POST['material_cost'];
$sales_tax=$_POST['sales_tax'];
$shipping_cost=$_POST['shipping_cost'];
// section 2 row 1 //
$work_performed=$_POST['work_performed'];
// section 3 cloumn 1 row 1 - 5 //
$work_date1=(isset($_POST['work_date1']) AND !empty($_POST['work_date1'])? $_POST['work_date1'] : '');
$work_date2=(isset($_POST['work_date2']) AND !empty($_POST['work_date2'])? $_POST['work_date2'] : '');
$work_date3=(isset($_POST['work_date3']) AND !empty($_POST['work_date3'])? $_POST['work_date3'] : '');
$work_date4=(isset($_POST['work_date4']) AND !empty($_POST['work_date4'])? $_POST['work_date4'] : '');
$work_date5=(isset($_POST['work_date5']) AND !empty($_POST['work_date5'])? $_POST['work_date5'] : '');
// section 3 column 2 row 1 - 5 //
$tech_name1=(isset($_POST['tech_name1']) AND !empty($_POST['tech_name1'])? $_POST['tech_name1'] : '');
$tech_name2=(isset($_POST['tech_name2']) AND !empty($_POST['tech_name2'])? $_POST['tech_name2'] : '');
$tech_name3=(isset($_POST['tech_name3']) AND !empty($_POST['tech_name3'])? $_POST['tech_name3'] : '');
$tech_name4=(isset($_POST['tech_name4']) AND !empty($_POST['tech_name4'])? $_POST['tech_name4'] : '');
$tech_name5=(isset($_POST['tech_name5']) AND !empty($_POST['tech_name5'])? $_POST['tech_name5'] : '');
// section 3 column 3 row 1 - 5 //
$cost_code1=(isset($_POST['cost_code1']) AND !empty($_POST['cost_code1'])? $_POST['cost_code1'] : '');
$cost_code2=(isset($_POST['cost_code2']) AND !empty($_POST['cost_code2'])? $_POST['cost_code2'] : '');
$cost_code3=(isset($_POST['cost_code3']) AND !empty($_POST['cost_code3'])? $_POST['cost_code3'] : '');
$cost_code4=(isset($_POST['cost_code4']) AND !empty($_POST['cost_code4'])? $_POST['cost_code4'] : '');
$cost_code5=(isset($_POST['cost_code5']) AND !empty($_POST['cost_code5'])? $_POST['cost_code5'] : '');
// section 3 column 4 row 1 - 5 //
$pay_rate1=(isset($_POST['pay_rate1']) AND !empty($_POST['pay_rate1'])? $_POST['pay_rate1'] : '');
$pay_rate2=(isset($_POST['pay_rate2']) AND !empty($_POST['pay_rate2'])? $_POST['pay_rate2'] : '');
$pay_rate3=(isset($_POST['pay_rate3']) AND !empty($_POST['pay_rate3'])? $_POST['pay_rate3'] : '');
$pay_rate4=(isset($_POST['pay_rate4']) AND !empty($_POST['pay_rate4'])? $_POST['pay_rate4'] : '');
$pay_rate5=(isset($_POST['pay_rate5']) AND !empty($_POST['pay_rate5'])? $_POST['pay_rate5'] : '');
// section 3 column 5 row 1 - 5 //
$total_hours1=(isset($_POST['total_hours1']) AND !empty($_POST['total_hours1'])? $_POST['total_hours1'] : '');
$total_hours2=(isset($_POST['total_hours2']) AND !empty($_POST['total_hours2'])? $_POST['total_hours2'] : '');
$total_hours3=(isset($_POST['total_hours3']) AND !empty($_POST['total_hours3'])? $_POST['total_hours3'] : '');
$total_hours4=(isset($_POST['total_hours4']) AND !empty($_POST['total_hours4'])? $_POST['total_hours4'] : '');
$total_hours5=(isset($_POST['total_hours5']) AND !empty($_POST['total_hours5'])? $_POST['total_hours5'] : '');
// section 3 column 6 row 5
$hours_subtotal1=(isset($_POST['hours_subtotal1']) AND !empty($_POST['hours_subtotal1'])? $_POST['hours_subtotal1'] : '');
$hours_subtotal2=(isset($_POST['hours_subtotal2']) AND !empty($_POST['hours_subtotal2'])? $_POST['hours_subtotal2'] : '');
$hours_subtotal3=(isset($_POST['hours_subtotal3']) AND !empty($_POST['hours_subtotal3'])? $_POST['hours_subtotal3'] : '');
$hours_subtotal4=(isset($_POST['hours_subtotal4']) AND !empty($_POST['hours_subtotal4'])? $_POST['hours_subtotal4'] : '');
$hours_subtotal5=(isset($_POST['hours_subtotal5']) AND !empty($_POST['hours_subtotal5'])? $_POST['hours_subtotal5'] : '');
// End of form totals //
$total_hours=$_POST['total_hours'];
$material_total=$_POST['material_total'];
$labor_cost=$_POST['labor_cost'];
$grand_total=$_POST['grand_total'];