本篇文章给大家分享的内容是PHP数据库增删改查 ,有着一定的参考价值,有需要的朋友可以参考一下
Register_2018411.php <body> <form name = "frm" action ="insert_2018411.php" method = "post"> Name<input type = "text" name= "txtName"/> <br/> Age<input type = "text" name ="txtAge"/> <br/> Gender <input type = "radio" name ="rdGender" value = "1">Male <input type = "radio" name ="rdGender" value = "0">Female <br/> <input type = "submit" name ="sbtsubmit" value = "Register"/> </form> </body> insert_2018411.php <?php $name = $_POST['txtName']; $age = $_POST['txtAge']; $gender = $_POST['rdGender']; $db =mysqli_connect("localhost","root","1234"); mysqli_select_db($db,"studentdb"); $in="insert intostudentinfotbl(stuName,stuAge,stuGender)values('$name','$age','$gender')"; mysqli_query($db,$in); header("location:show_2018411.php"); ?> show_2018411.php <?php $db =mysqli_connect("localhost","root","1234"); mysqli_select_db($db,"studentdb"); $select = "select * fromstudentinfotbl"; $result = mysqli_query($db,$select); ?> <table border = 1> <tr><td>stuName</td><td>stuAge</td><td>stuGender</td><td>delete</td><td>update</td></tr> <?php while($resArry=mysqli_fetch_array($result)){?> <tr> <td><?phpecho $resArry[1]; ?></td> <td><?phpecho $resArry[2]; ?></td> <td><?php if($resArry[3]==1){ echo"男"; }else{ echo"女"; } ?></td> <td><?phpecho "<a href = 'delete_2018411.php?id=$resArry[0]'> delete</a>"; ?></td> <td><?phpecho "<a href = 'updateFirst.php?id=$resArry[0]'> update</a>"; ?></td> </tr> <?php } ?> </table> delete_2018411.php <?php $db = mysqli_connect("localhost","root","1234"); mysqli_select_db($db,"studentdb"); $id = $_GET['id']; $delete = "delete from studentinfotblwhere stuId = $id"; mysqli_query($db,$delete); header("location:show_2018411.php"); ?> updateFirst.php <?php session_start(); $id = $_GET['id']; echo $id; $_SESSION['id']=$id; ?> <body> <form name = "frm" action ="update_2018411.php" method = "post"> Name<input type = "text" name= "txtName"/> <br/> Age<input type = "text" name ="txtAge"/> <br/> Gender <input type = "radio" name ="rdGender" value = "1">Male <input type = "radio" name ="rdGender" value = "0">Female <br/> <input type = "submit" name ="sbtsubmit" value = "OK"/> </form> </body> update_2018411.php <?php session_start(); $db = mysqli_connect("localhost","root","1234"); mysqli_select_db($db,"studentdb"); $name = $_POST['txtName']; $age = $_POST['txtAge']; $gender = $_POST['rdGender']; $id = $_SESSION['id']; if(1){ $update= "update studentinfotbl setstuName = '$name',stuAge = $age,stuGender = $gender wherestuId =$id;"; mysqli_query($db,$update); } session_destroy(); header("location:show_2018411.php"); ?>
相关推荐:
以上是PHP数据库增删改查的详细内容。更多信息请关注PHP中文网其他相关文章!

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增强codemodocultion,可验证性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

选择DependencyInjection(DI)用于大型应用,ServiceLocator适合小型项目或原型。1)DI通过构造函数注入依赖,提高代码的测试性和模块化。2)ServiceLocator通过中心注册获取服务,方便但可能导致代码耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)启用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替换loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化进行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

tomakephpapplicationsfaster,关注台词:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

到ImprovephPapplicationspeed,关注台词:1)启用opcodeCachingwithapCutoredUcescriptexecutiontime.2)实现databasequerycachingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandredececonnection.4 limitsclection.4.4

依赖注入(DI)通过显式传递依赖关系,显着提升了PHP代码的可测试性。 1)DI解耦类与具体实现,使测试和维护更灵活。 2)三种类型中,构造函数注入明确表达依赖,保持状态一致。 3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

databasequeryOptimizationinphpinvolVolVOLVESEVERSEVERSTRATEMIESOENHANCEPERANCE.1)SELECTONLYNLYNESSERSAYCOLUMNSTORMONTOUMTOUNSOUDSATATATATATATATATATATRANSFER.3)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Dreamweaver CS6
视觉化网页开发工具

Atom编辑器mac版下载
最流行的的开源编辑器