PHP modifies database data
Query a condition data first, want to click Modify can pop up another window, the window has all the table field (Control form), in the control of the window to modify the current data. How should I make it?
Header ("Content-type:text/html;charset=utf-8");
$serverName = "192.168.1.110,12590"; Local is represented locally, if you use IP without parentheses, 1433 means port
For example $servername = "127.0.0.1,1433";
$database = "ee";
$uid = "sa";
$pwd = "ee234";
try {
$conn = new PDO ("sqlsrv:server= $serverName;D atabase = $database", $uid, $pwd);
}
catch (Pdoexception $e) {
Die ("Error Connecting to SQL Server". $e);
}
Echo '
";
Echo '
';Echo '
Employee Profiles at a glance
';Echo '
' Echo '
_identify |
Department system |
Work Department |
Office |
post name |
position rank |
position level |
Grade |
Employee number |
Employee name |
Delete |
modify | '; Echo ', ' echo ', ' echo ' \ n '; if (Isset ($_post[' submit1 ')) {//sql statement $bh = $_post[' name ']; $stmt = $conn->query ("Select _identify, departmental system, work Department, office, job title, position rank, position level, grade, employee number, employee name from Employee Profile table where employee number = ' $BH '"); while (List ($_identify,$ Department system, $ work Department, $ office, $ job title, $ job rank, $ job level, $ grade, employee number, employee name) = $stmt->fetch (pdo::fetch_num)) { echo "
'; Echo '
'. $_identify. ' | '; Echo '
'. $ sectoral system. ' | '; Echo '
'. $ work Department. ' | '; Echo '
'. $ office. ' | '; Echo '
'. $ post name. ' | '; Echo '
'. $ post rank. ' | '; Echo '
'. $ position level. ' | '; Echo '
'. $ grades. ' | '; Echo '
'. $ employee number. ' | '; Echo '
'. $ employee name. ' | '; Echo '
'." Delete "." | '; Echo '
'." Modify the ". ' | '; Echo '
';}Echo '
';
}
ElseIf (Isset ($_post[' submit2 ')) {
$XM = $_post[' name1 ');
$stmt = $conn->query ("Select _identify, departmental system, work Department, office, job title, position rank, position level, grade, employee number, employee name from Employee Profile table where employee name like '% '. $xm." %'");
while (List ($_identify,$ Department system, $ work Department, $ office, $ job title, $ job rank, $ job level, $ grade, employee number, employee name) = $stmt->fetch (pdo::fetch_num)) {
echo "
";
Echo '';
Echo ''. $_identify. '';
Echo ''. $ sectoral system. '';
Echo ''. $ work Department. '';
Echo ''. $ office. '';
Echo ''. $ post name. '';
Echo ''. $ post rank. '';
Echo ''. $ position level. '';
Echo ''. $ grades. '';
Echo ''. $ employee number. '';
Echo ''. $ employee name. '';
Echo ''." Delete "."';
Echo ''." Modify the ". '';
Echo '';
}
Echo '';
}
else{
$stmt = $conn->query ("Select _identify, departmental system, work Department, office, job title, position rank, position level, grade, employee number, employee name from Employee File table");
while (List ($_identify,$ Department system, $ work Department, $ office, $ job title, $ job rank, $ job level, $ grade, employee number, employee name) = $stmt->fetch (pdo::fetch_num)) {
echo "
";
Echo ';
echo ". $_identify.";
Echo '. $ departmental system. ';
Echo '. $ work Department. ';
Echo '. $ office. ';
Echo '. $ job title. ';
Echo '. $ post rank. ';
Echo '. $ position level. ';
Echo '. $ grades. ';
Echo '. $ employee number. ';
Echo '. $ employee name. ';
Echo '. ' Delete the ".";
Echo '. ' Modify the ".";
Echo ';
}
Echo ';
}
?>
------to solve the idea----------------------
Queries and modifications cannot be completed at the same time
Besides, have you changed the new page?
------to solve the idea----------------------
Click to modify these with JS and Ajax implementation will be better.