我有以下代码:
app.post('/pepe/query/', function(req, res) {
var query = "SELECT * FROM mutations";
if (req.body.start.length !== 0) { //From an HTML form
query = query + " WHERE pos>=" + req.body.start;
}
app.get('/pepe/query/:number', function(req2, res2) {
var pages = 10 * req.param2("number") - 10;
query2 = query + " LIMIT " + pages + ", 10";
if (req.body.output == 1) {
pool.query(query2, function select(error, results, fields) {
res.render('index.html',{data:results, error:null});
});
} else if (req.body.output == 2) {
query2 = "SELECT count(*) FROM (" + query + ") AS table1";
pool.query(query2, function select(error, results, fields) {
res.send(results);
});
}
});
});
但是,这种方法不起作用,因为我通过POST
将表单中的信息发送到/pepe/query
,但它不起作用。
我的目标是转到/pepe/query/3
,然后转到第3页(结果21-30)。
答案 0 :(得分:0)
这样的事情:
app.get('/pepe/query/', function(req, res) {
var start = req.query.start;
var number = req.query.number;
//Logic here.
res.send(results);
});
<form method="GET" action="/pepe/query/">
<input name="start" type="text" id="search" />
<input name="number" type="text" id="number" />
</form>