欢迎使用浙教版教材目录查询系统。本系统提供了浙江教育出版社出版的各学科教材的目录信息,方便师生查找所需教材内容。
使用方法
-
选择要查询的学科
-
输入教材名称或版本
-
点击搜索按钮
搜索结果
配套JavaScript脚本(script.js)
javascript
const subject = document.getElementById('subject');
const keyword = document.getElementById('keyword');
const searchResults = document.getElementById('search-results');subject.addEventListener('change', ()=> {// 根据学科获取教材目录信息fetch(`get-catalog.php?subject=${subject.value}`).then(res => res.json()).then(data => {// 动态生成教材目录信息let html = '';data.forEach(item => {html += `${item.name}${item.version}
查看目录
`;});searchResults.innerHTML = html;});
});keyword.addEventListener('keyup', () => {// 根据教材名称或版本搜索教材目录信息fetch(`search-catalog.php?subject=${subject.value}&keyword=${keyword.value}`).then(res => res.json()).then(data => {// 动态生成教材目录信息let html = '';data.forEach(item => {html += `${item.name}${item.version}
查看目录
`;});searchResults.innerHTML = html;});
});后端PHP代码get-catalog.php
php
query($sql);// 将查询结果转换为JSON格式
$data = array();
while ($row = $result->fetch_assoc()) {$data[] = $row;
}// 输出JSON数据
echo json_encode($data);
?>search-catalog.php
php
query($sql);// 将查询结果转换为JSON格式
$data = array();
while ($row = $result->fetch_assoc()) {$data[] = $row;
}// 输出JSON数据
echo json_encode($data);
?>