<?php
$con = mysqli_connect(
'207.148.19.37', /* The host to connect to 连接MySQL地址 */
'test', /* The user to connect as 连接MySQL用户名 */
'123456', /* The password to use 连接MySQL密码 */
'mydatabase'); /* The default database to query 连接数据库名称*/
if (!$con) {
printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
exit;
}
//$sql="insert into student values('zbc','男','itcast0005',23);";
//
//$result = mysqli_query($conn,$sql);
//
//echo "ok";
$sql = "select * from student";
$rs = mysqli_query($con,$sql);
$r= mysqli_fetch_all($rs,MYSQLI_ASSOC);
echo json_encode($r)
?>
网友评论