PHP Correcting database data

Source: Internet
Author: User
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 ' ';Echo ' ' Echo ' '; 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 ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' '; Echo ' ';}Echo '

Employee Profiles at a glance

_identify Department system Work Department Office post name position rank position level Grade Employee number Employee name Delete modify
'. $_identify. ''. $ sectoral system. ''. $ work Department. ''. $ office. ''. $ post name. ''. $ post rank. ''. $ position level. ''. $ grades. ''. $ employee number. ''. $ employee name. ''." Delete "."'." Modify the ". '
';

}
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.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.