php修改数据库数据
先查询某条件数据,希望点击修改能够弹出另外一窗口,该窗口有所有表的字段(控件形式表现),在该窗口的控件中对当前数据进行修改。请问应该如何实现?
<br /><!DOCTYPE HTML><br /><html> <br /><body><br /><br /><form method="POST"><br /><input type="reset" value="重置"><p><br />员工编号:<input type="text" value="<?php if(isset($_POST['name'])){echo $_POST['name'];}?>" name="name"><br /><input type="submit" name="submit1" value="查询"><p><br />员工姓名:<input type="text" value="<?php if(isset($_POST['name1'])){echo $_POST['name1'];}?>" name="name1"><br /><input type="submit" name="submit2" value="查询"><p><br /></form><br /></body><br /><?php<br /><br /> header("Content-type:text/html;charset=utf-8");<br /> $serverName = "192.168.1.110,12590"; //local表示为本地,如果你用IP就不用括号了,1433表示端口<br /> //比如$serverName = "127.0.0.1,1433"; <br /> $database = "ee";<br /> $uid = "sa";<br /> $pwd = "ee234";<br /><br /> try {<br /> $conn = new PDO( "sqlsrv:server=$serverName;Database = $database", $uid, $pwd); <br /> }<br /><br /> catch( PDOException $e ) {<br /> die( "Error connecting to SQL Server".$e ); <br /> }<br />echo '<table border="1" align="center width=90%">';<br />echo '<caption><h1 id="员工档案一览">员工档案一览</h1></caption>';<br />echo '<tr bgcolor="#cccccc">';<br /><br />echo '<th>_Identify</th><th>部门体系</th><th>工作部门</th><th>办事处</th><th>岗位名称</th><th>职位职级</th><th>职位层级</th><th>职系</th><th>员工编号</th><th>员工姓名</th><th>删除</th><th>修改</th>';<br />echo "<br>";<br />echo "<p></p>";<br />echo "\n";<br /><br /> if(isset($_POST['submit1'])) { <br /> //SQL语句<br /> $bh= $_POST['name'];<br /> $stmt= $conn->query("select _Identify,部门体系,工作部门,办事处,岗位名称,职位职级,职位层级,职系,员工编号,员工姓名 from 员工档案表 where 员工编号='$bh'");<br /> while (list ($_Identify,$部门体系, $工作部门, $办事处, $岗位名称, $职位职级, $职位层级, $职系, $员工编号, $员工姓名) = $stmt->fetch(PDO::FETCH_NUM)){<br /> echo "<center>";<br /> echo '<tr>';<br /> echo '<td>'.$_Identify.'</td>';<br /> echo '<td>'.$部门体系.'</td>';<br /> echo '<td>'.$工作部门.'</td>';<br /> echo '<td>'.$办事处.'</td>';<br /> echo '<td>'.$岗位名称.'</td>';<br /> echo '<td>'.$职位职级.'</td>';<br /> echo '<td>'.$职位层级.'</td>';<br /> echo '<td>'.$职系.'</td>';<br /> echo '<td>'.$员工编号.'</td>';<br /> echo '<td>'.$员工姓名.'</td>';<br /> echo '<td>'."<a href='del.php?id=$_Identify'>删除</a>".'</td>';<br /> echo '<td>'."<a href='alter.php?id=$_Identify'>修改</a>".'</td>';<br /> echo '</tr>';<br /> }<br /> echo '</table>';<br /> <br /> }<br /> elseif(isset($_POST['submit2'])){<br /> $xm= $_POST['name1'];<br /> $stmt= $conn->query("select _Identify,部门体系,工作部门,办事处,岗位名称,职位职级,职位层级,职系,员工编号,员工姓名 from 员工档案表 where 员工姓名 like'%".$xm."%'");<br /> while (list ($_Identify,$部门体系, $工作部门, $办事处, $岗位名称, $职位职级, $职位层级, $职系, $员工编号, $员工姓名) = $stmt->fetch(PDO::FETCH_NUM)){<br /> echo "<center>";<br /> echo '<tr>';<br /> echo '<td>'.$_Identify.'</td>';<br /> echo '<td>'.$部门体系.'</td>';<br /> echo '<td>'.$工作部门.'</td>';<br /> echo '<td>'.$办事处.'</td>';<br /> echo '<td>'.$岗位名称.'</td>';<br /> echo '<td>'.$职位职级.'</td>';<br /> echo '<td>'.$职位层级.'</td>';<br /> echo '<td>'.$职系.'</td>';<br /> echo '<td>'.$员工编号.'</td>';<br /> echo '<td>'.$员工姓名.'</td>';<br /> echo '<td>'."<a href='del.php?id=$_Identify'>删除</a>".'</td>';<br /> echo '<td>'."<a href='alter.php?id=$_Identify'>修改</a>".'</td>';<br /> echo '</tr>';<br /> }<br /> echo '</table>';<br /> }<br /> else{<br /> $stmt= $conn->query("select _Identify,部门体系,工作部门,办事处,岗位名称,职位职级,职位层级,职系,员工编号,员工姓名 from 员工档案表");<br /> while (list ($_Identify,$部门体系, $工作部门, $办事处, $岗位名称, $职位职级, $职位层级, $职系, $员工编号, $员工姓名) = $stmt->fetch(PDO::FETCH_NUM)){<br /> echo "<center>";<br /> echo '<tr>';<br /> echo '<td>'.$_Identify.'</td>';<br /> echo '<td>'.$部门体系.'</td>';<br /> echo '<td>'.$工作部门.'</td>';<br /> echo '<td>'.$办事处.'</td>';<br /> echo '<td>'.$岗位名称.'</td>';<br /> echo '<td>'.$职位职级.'</td>';<br /> echo '<td>'.$职位层级.'</td>';<br /> echo '<td>'.$职系.'</td>';<br /> echo '<td>'.$员工编号.'</td>';<br /> echo '<td>'.$员工姓名.'</td>';<br /> echo '<td>'."<a href='del.php?id=$_Identify'>删除</a>".'</td>';<br /> echo '<td>'."<a href='alter.php?id=$_Identify'>修改</a>".'</td>';<br /> echo '</tr>';<br /> }<br /> echo '</table>';<br /> }<br />?><br /></html><br />
------解决思路----------------------
查询和修改不能同时完成
再说你 修改 不已经产生新页面了吗?
------解决思路----------------------
点击修改这些用js 和 ajax 实现会好点。

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!
