javascript - 使用 nodejs 和 mysql 进行多个复选框过滤
问题描述
我正在使用 Node JS 和 Mysql 处理复选框过滤器。但是,我很难处理它。我想做的是,我想显示用户检查的类别(科学、技术、教育)。
在我的 ejs 文件中,我有以下代码:
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" name ="Science" class="custom-control-input" id="science-cat" value ="science" >
<label class="custom-control-label" for="defaultInline1">Science</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" name="Technology" class="custom-control-input" id="technology-cat" value="technology">
<label class="custom-control-label" for="defaultInline2">Technology</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="education-cat" value="Education" onchange="location = this.value;">
<label class="custom-control-label" for="defaultInline3">Education</label>
</div>
在我的 app.js 文件中,我有以下代码:
app.get('/DownloadMaterials',function(req, res){
var sort = req.query.sort;
if(sort == null){
sort = "DESC";
}
var query = 'Select downloads.userId,steam_category.steamName,downloads.fileType,downloads.fileName,downloads.downloadDate,faculty.fName,faculty.lName from downloads LEFT JOIN faculty ON downloads.userId=faculty.facultyId LEFT JOIN steam_category ON downloads.categoryId=steam_category.steamId ORDER BY downloads.downloadDate '+sort+'';
db.query(query,function(err,result){
if(err){
throw err;
}
res.render('pages/DownloadMaterials.ejs',{
siteTitle: "Test",
pageTitle: "E-Learning Management System",
items: result
});
});
});
解决方案
推荐阅读
- python - 为什么这个 python bs4&csv writer 代码写在 BOM 中?
- php - 当语言为阿拉伯语时,get_the_date() 返回英语年和日
- arduino - Adafruit 数据屏蔽 RTC 给出错误
- python - 我可以使用 MIP 优化独立电池并输出充电/放电模式吗?
- csv - 在 db2 on cloud Lite 版本中,是否可以将 sql 查询结果导出为 csv?如何?
- c# - 使用具有多个条件的 Linq 进行迭代时出现编译错误
- visual-studio-code - 如何重新映射
转到 VSCodeVim 中的行号 - angular - Angular如何在从API获取数据时添加加载器动画?
- python - 如何在 Pandas 数据框中查找值
- c++ - 如何将class.cpp和class.hpp编译成一个.o文件?