小智..
55
要使用Ajax + jQuery检索数据,您必须编写以下代码:
$(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);
}
});
});
});
Manage Student Details
对于mysqli连接,请写下:
$con=mysqli_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysqli_error());
}
?>
要显示数据库中的数据,您必须写下:
include("connection.php");
mysqli_select_db("samples",$con);
$result=mysqli_query("select * from student",$con);
echo "
Roll No | Name | Address | Stream | Status |
while($data = mysqli_fetch_row($result))
{
echo "
";echo "
$data[0]";echo "
$data[1]";echo "
$data[2]";echo "
$data[3]";echo "
$data[4]";echo "
";}
echo "
";?>
请注意:对于`mysql_*`函数没有**支持**,它们是[**正式弃用**](https://wiki.php.net/rfc/mysql_deprecation),**不再保持**并将来[**删除**](http://php.net/manual/en/function.mysql-connect.php#warning).您应该使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/mysqli)更新代码,以确保将来的项目功能. (7认同)