每个MySQL的结果在page1.php中我打电话使用Ajax 使page2.php(汽车或船的Lijst)。之后,我想使用另一个Ajax查询对结果进行排序。排序使用Ajax
上page1.php中的2个jqueries代码:
function display_cars() {
jQuery.ajax({
type: 'GET',
url: 'page2.php?action=cars',
success: function(msg) {
$('#show_results').html(msg);
}
});
}
function display_boats() {
jQuery.ajax({
type: 'GET',
url: 'page2.php?action=boats',
success: function(msg) {
$('#show_results').html(msg);
}
});
}
在使page2.php我有mysql的查询:
if ($action == "car") {
$sql = "SELECT *
FROM table
WHERE cars = $cars
ORDER BY date DESC
";
}
if ($action == "boats") {
$sql = "SELECT *
FROM table
WHERE boats = $boats
ORDER BY date DESC
";
}
这个MySQL查询的结果:
梅赛德斯:50
BMW:10
本田:20
现在我想每个结果通过使用Ajax(ORDER BY量DESC)排序。
我正在考虑使用php会话,但我不确定它是否是正确的解决方案。
请参阅http://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple- sql-query – Strawberry
@Strawberry谢谢。我已经做了。你的意思是我的问题不够清楚,我不得不添加更多的信息和解释? –
我认为“元问题”的接受答案是不言自明的 – Strawberry