PHP数据库增删改查
本篇文章给大家分享的内容是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中文网其他相关文章!

热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

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

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

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

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

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

PHP主要是过程式编程,但也支持面向对象编程(OOP);Python支持多种范式,包括OOP、函数式和过程式编程。PHP适合web开发,Python适用于多种应用,如数据分析和机器学习。

PHP用于构建动态网站,其核心功能包括:1.生成动态内容,通过与数据库对接实时生成网页;2.处理用户交互和表单提交,验证输入并响应操作;3.管理会话和用户认证,提供个性化体验;4.优化性能和遵循最佳实践,提升网站效率和安全性。

PHP适合网页开发和快速原型开发,Python适用于数据科学和机器学习。1.PHP用于动态网页开发,语法简单,适合快速开发。2.Python语法简洁,适用于多领域,库生态系统强大。

PHP起源于1994年,由RasmusLerdorf开发,最初用于跟踪网站访问者,逐渐演变为服务器端脚本语言,广泛应用于网页开发。Python由GuidovanRossum于1980年代末开发,1991年首次发布,强调代码可读性和简洁性,适用于科学计算、数据分析等领域。

PHP的核心优势包括易于学习、强大的web开发支持、丰富的库和框架、高性能和可扩展性、跨平台兼容性以及成本效益高。1)易于学习和使用,适合初学者;2)与web服务器集成好,支持多种数据库;3)拥有如Laravel等强大框架;4)通过优化可实现高性能;5)支持多种操作系统;6)开源,降低开发成本。

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP适用于Web开发和内容管理系统,Python适合数据科学、机器学习和自动化脚本。1.PHP在构建快速、可扩展的网站和应用程序方面表现出色,常用于WordPress等CMS。2.Python在数据科学和机器学习领域表现卓越,拥有丰富的库如NumPy和TensorFlow。

PHP仍然流行的原因是其易用性、灵活性和强大的生态系统。1)易用性和简单语法使其成为初学者的首选。2)与web开发紧密结合,处理HTTP请求和数据库交互出色。3)庞大的生态系统提供了丰富的工具和库。4)活跃的社区和开源性质使其适应新需求和技术趋势。
