栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Jquery Ajax从Mysql检索数据

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Jquery Ajax从Mysql检索数据

为了使用Ajax + jQuery检索数据,您应该编写以下代码:

 <html> <script type="text/javascript" src="jquery-1.3.2.js"> </script> <script type="text/javascript"> $(document).ready(function() {    $("#display").click(function() {      $.ajax({    //create an ajax request to display.php        type: "GET",        url: "display.php",          dataType: "html",   //expect html to be returned  success: function(response){          $("#responsecontainer").html(response);  //alert(response);        }    });});});</script><body><h3 align="center">Manage Student Details</h3><table border="1" align="center">   <tr>       <td> <input type="button" id="display" value="Display All Data" /> </td>   </tr></table><div id="responsecontainer" align="center"></div></body></html>

对于mysqli连接,请编写以下代码:

<?php $con=mysqli_connect("localhost","root","");

为了显示数据库中的数据,您应该这样编写:

<?phpinclude("connection.php");mysqli_select_db("samples",$con);$result=mysqli_query("select * from student",$con);echo "<table border='1' ><tr><td align=center> <b>Roll No</b></td><td align=center><b>Name</b></td><td align=center><b>Address</b></td><td align=center><b>Stream</b></td></td><td align=center><b>Status</b></td>";while($data = mysqli_fetch_row($result)){       echo "<tr>";    echo "<td align=center>$data[0]</td>";    echo "<td align=center>$data[1]</td>";    echo "<td align=center>$data[2]</td>";    echo "<td align=center>$data[3]</td>";    echo "<td align=center>$data[4]</td>";    echo "</tr>";}echo "</table>";?>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/400656.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号