php mysql edit table form revert the table's fields to it's original values -
i have form editing table in database, when edit table using forms nothing , give no errors. when edit phpmyadmin works, if edit using php form reverts fields values it's original values gave in add form. i'm using pdo class connect mysql database.
here php code edit table, it's kinda miss know :/, note store form values in arrays because have loop in creating form give fields each employee , of course change name of fields using prefix:
<?php if((isset($_get['action'])) , ($_get['action'] == 'edit')){ //get employees info $employees = pdo_fetchall("select * employees"); //echo "<script>alert('aa');</script>"; //initial values $official_days_e = array(); $official_vacations_e = array(); $attendance_days_e = array(); $present_days_e = array(); $vacations_e = array(); $vacations_record_e = array(); $table_namee = $_post['table_name']; //echo "<script>alert('bb');</script>"; foreach($employees $employee){ $official_days_e[] = $_post[$employee['emp_id'].'_official_days_e']; $official_vacations_e[] = $_post[$employee['emp_id'].'_official_vacations_e']; $attendance_days_e[] = $_post[$employee['emp_id'].'_attendance_days_e']; $present_days_e[] = $_post[$employee['emp_id'].'_present_days_e']; $vacations_e[] = $_post[$employee['emp_id'].'_vacations_e']; $vacations_record_e[] = $_post[$employee['emp_id'].'_vacations_record_e']; } //echo "<script>alert('$official_days_e[1]');</script>"; //edit values in db $countt = 0; foreach($employees $employee){ $empl_id = $employee['id']; $official_dayss_e = $official_days_e[$countt]; $official_vacationss_e = $official_vacations_e[$countt]; $attendance_dayss_e = $attendance_days_e[$countt]; $present_dayss_e = $present_days_e[$countt]; $vacationss_e = $vacations_e[$countt]; $vacations_recordss_e = $vacations_record_e[$countt]; $countt = $countt+1; $attendance->query("update $table_namee set `official_days` = $official_dayss_e, `official_vacations` = $official_vacationss_e, `attendance_days` = $attendance_dayss_e, `present_days` = $present_dayss_e, `vacations` = $vacationss_e, `vacations_record` = $vacations_recordss_e") or die($attendance->errorinfo()); } //echo "<script>alert('$countt');</script>"; //echo "<script>alert('done');</script>"; echo "<script>playsound('js/sounds/sound1.ogg');</script>"; echo "<script>$.mininoty('done', 'success');</script>"; //echo "<script>settimeout(function(){ window.location='attendance.php'; }, 1200);</script>"; }
the code works no errors. note add form have same code, ram storing problem ?, tried change variables names didn't help.
Comments
Post a Comment