使用tablesorter进行Jquery、php、mysql表排序

使用tablesorter进行Jquery、php、mysql表排序,php,jquery,mysql,tablesorter,Php,Jquery,Mysql,Tablesorter,我正在做一个非常简单的站点,我需要一个表排序系统,我已经设置了表,它从MySQL表反馈数据,但我似乎无法对行进行排序,有什么想法吗 <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="main.css"/> <title>Assessment 2</title> <script type="text/javascript" src="jq

我正在做一个非常简单的站点,我需要一个表排序系统,我已经设置了表,它从MySQL表反馈数据,但我似乎无法对行进行排序,有什么想法吗

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="main.css"/>
<title>Assessment 2</title>
    <script type="text/javascript" src="jquery-1.11.1.min.js"></script> 
    <script type="text/javascript" src="jquery.tablesorter.js"></script> 
    <script type ="text/javascript">

        $(document).ready(function() 
            { 
                $("products").tablesorter(); 
            } 
        ); 
    </script>
</head>
<body>
    <?php
      include '\navigation\navigation.php';
    ?>

<div class="center">
    <h1>Products</h1>



    <?php
        include "connectionlocalhost.php";


        $query = "SELECT * FROM products";
        $result = mysqli_query($connection, $query) or exit ("Error $query . ".mysqli_error());

            echo "<table border='1' id='products' class='tablesorter'>
            <thead>
                <tr>
                    <th>Product Name</th>
                    <th>Product Price</th>
                    <th>Product Image</th>
                </tr>
                </thead>
                <tbody>";   

        while ($row = mysqli_fetch_assoc($result)){
            echo "<tr>";
            echo "<td>". $row['productname'] . "</td>";
            echo "<td>". $row['productprice'] . "</td>";
            echo "</td>";

            }
            mysqli_free_result($result);



        echo "</tbody></table>";

    ?>
</div>

</body>
</html>

评估2
$(文档).ready(函数()
{ 
$(“产品”).tablesorter();
} 
); 
产品

我知道其中一列是空的,只是出于测试目的,我认为mysql查询有错误。

您需要在“产品”中添加磅号
#

关于/参考表格的“id”


试试
$(“#产品”).tablesorter()使用磅符号作为“id”。或
$(“.tablesorter”).tablesorter()来自表的类名。#产品有效,我不敢相信我忽略了这一点,谢谢。不客气。访问,然后返回下面给出的答案,并勾选复选标记,如图所示。这将标志着问题已经解决。
$("products").tablesorter();
<table border='1' id='products' class='tablesorter'>
$("#products").tablesorter();