旧版服务端
This commit is contained in:
1 parent
3429c8b402
commit
25bbb5f9c8
971 files changed
+87141
-40
No files matched your search
Executable
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// 声明JSON内容类型
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
||||
// 引用配置,建立数据库连接
|
||||
require_once 'ApiConfig.php';
|
||||
$conn = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
|
||||
|
||||
// 检查连接是否成功
|
||||
if ($conn->connect_error) {
|
||||
die("连接失败: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// 查询数据库中符合条件的记录
|
||||
$sql = "SELECT * FROM 首页课程列表";
|
||||
$result1 = $conn->query($sql);
|
||||
|
||||
|
||||
// 如果查询结果不为空,则进行二次查询
|
||||
if ($result1->num_rows > 0) {
|
||||
// 获取查询结果
|
||||
$data = array();
|
||||
while ($row = $result1->fetch_assoc()) {$data[] = $row;}
|
||||
|
||||
echo json_encode(["result" => "首页课程列表", "ListData" => $data]);
|
||||
} else {
|
||||
echo json_encode(["result" => "未找到课程列表!", "ListData" => null]);
|
||||
}
|
||||
|
||||
// 关闭数据库连接
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in new issue
Block a user