使用php,ajax和jquery对mysql表进行排序
Ok here is the deal i am building a messaging system by php,ajax,jquery and mysql i add the new message and i add in 2 rows now what i want to do is to send an ajax request to server and recieve an updated version of the table but sorted So how can i do so
好的,这是我正在通过php,ajax,jquery和mysql构建消息系统的交易我添加新消息,我现在添加2行我想要做的是向服务器发送ajax请求并收到更新版本的桌子,但排序所以我该怎么做
//here i add and call the message the message
//在这里我添加并将消息称为消息
function addMsg()
{
//alert(post);
$.get("db.php",$('form').serialize(),
function(data){
getMsg(data);},"html");
}
function getMsg(data) { alert(data);
$("#t1").append(data); } //php
function getMsg(data){alert(data); $( “#T1”)追加(数据)。 } // php
".""."".$row["col"]."".$row["col"]."".$row["col"].""; } ?>//Now for sorting //javascript
//现在排序// javascript
function sort()
{
$.ajax({
url: "sort.php",
dataType: "text",
success: function(data){
$("t1").text(data);
}
});
}
//php
$result = mysql_query("SELECT * FROM table ORDER BY col desc");
$ result = mysql_query(“SELECT * FROM table ORDER BY col desc”);
while($row = mysql_fetch_array($result))
{
echo "<tbody><tr><td>"."•"."</td><td>".$row["col"]."</td><td>".$row["col"]."</td><td></td><td></td><tr><td></td><td colspan='4'>".$row["col"]."</td></tr></tbody>";
}
?>
1 个解决方案
#1
Use ORDER BY when you do the SELECT. Check this: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html
执行SELECT时使用ORDER BY。请查看:http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html
更多相关文章
- 尽管“SQL语法错误”消息仍然成功执行
- 利用ApnsPHP包向IOS推送消息
- PHP结合memcacheq消息队列解决并发问题
- 如何使用php和mysql处理加密的私人消息
- 具有线程/回复的私人消息系统
- Oracle相当于MySQL代码“插入虚拟”以返回错误消息
- MYSQL错误代码和消息
- 如何使用try,catch在错误处理中打印消息
- 如何避免pro拖拉机中的“jasmin .suite() required”错误消息?