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>"."&#8226;"."</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

更多相关文章

  1. 尽管“SQL语法错误”消息仍然成功执行
  2. 利用ApnsPHP包向IOS推送消息
  3. PHP结合memcacheq消息队列解决并发问题
  4. 如何使用php和mysql处理加密的私人消息
  5. 具有线程/回复的私人消息系统
  6. Oracle相当于MySQL代码“插入虚拟”以返回错误消息
  7. MYSQL错误代码和消息
  8. 如何使用try,catch在错误处理中打印消息
  9. 如何避免pro拖拉机中的“jasmin .suite() required”错误消息?

随机推荐

  1. 使用Python写HTML 文件使用jinja2中的模
  2. 【项目实战】自监控-09-DataFrame索引操
  3. django / python:具有多个表的原始sql
  4. 在创建表时执行Django fixture
  5. 安装Python3.6.3+spyder
  6. Python:2D Numpy数组(矩阵) - 查找负数之和(
  7. python学习的第一天---
  8. 如何在python中使用命名组和datadict从正
  9. 【问题解决方案】ImportError: No module
  10. 120行python代码解锁10000分微信跳一跳