Javascript Tablesorter将不显示可排序的标题

Javascript Tablesorter将不显示可排序的标题,javascript,php,jquery,tablesorter,Javascript,Php,Jquery,Tablesorter,在过去的两个小时里,我一直在玩这个代码。我根本找不到错误。使用下面的代码,将显示表格标题和正文,但标题不可排序。我已经尝试过脚本代码的各种化身,但都没有用。我错过了什么 <!DOCTYPE html> <head> <script type="text/javascript" src="./jquery-1.11.1.min.js"></script> <script type="text/javascript

在过去的两个小时里,我一直在玩这个代码。我根本找不到错误。使用下面的代码,将显示表格标题和正文,但标题不可排序。我已经尝试过脚本代码的各种化身,但都没有用。我错过了什么

    <!DOCTYPE html>
    <head>
    <script type="text/javascript" src="./jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="./Mottie-tablesorter-c1ce076/js/jquery.tablesorter.js"></script>
    <script type="text/javascript">
    $(document).ready(function()
        {
            $("table").tablesorter();
        }
    );
    </script>
    </head>
    <?php
    /* Attempt MySQL server connection. Assuming you are running MySQL
    server with default setting (user 'root' with no password) */
    $link = mysqli_connect("localhost", "SECRET", "SECRET", "SECRET");

    // Check connection
    if($link === false){
        die("ERROR: Could not connect. " . mysqli_connect_error());
    }

    // Attempt select query execution
    $sql = "SELECT * FROM persons";
    if($result = mysqli_query($link, $sql)){
        if(mysqli_num_rows($result) > 0){
            echo "<table class=\"tablesorter\">";
            echo "<thead>";
             echo "<tr>";
             echo "<th>First Name</th>";
             echo "<th>Last Name</th>";
             echo "<th>Email</th>";
             echo "<th>FFID</th>";
             echo "<th>Street</th>";
             echo "<th>City</th>";
             echo "<th>State</th>";
             echo "<th>Zip</th>";
             echo "<th>Home Fire Dept</th>";
             echo "<th>Shirt Size</th>";
             echo "<th>Additional Shirts</th>";
             echo "<th>Friday Class</th>";
             echo "<th>Saturday Class</th>";
             echo "<th>Sunday Class</th>";
             echo "</tr>";
            echo "</thead>";
            while($row = mysqli_fetch_array($result)){
                echo "<tbody><tr>";
                    echo "<td>" . $row['first_name'] . "</td>";
                    echo "<td>" . $row['last_name'] . "</td>";
                    echo "<td>" . $row['email_address'] . "</td>";
                    echo "<td>" . $row['ffid_num'] . "</td>";
                    echo "<td>" . $row['address_street'] . "</td>";
                    echo "<td>" . $row['address_city'] . "</td>";
                    echo "<td>" . $row['address_state'] . "</td>";
                    echo "<td>" . $row['address_zip'] . "</td>";
                    echo "<td>" . $row['fire_dept'] . "</td>";
                    echo "<td>" . $row['wants_tshirt'] . "</td>";
                    echo "<td>" . $row['shirt_size'] . "</td>";
                    echo "<td>" . $row['additional_shirts'] . "</td>";
                    echo "<td>" . $row['friday_class'] . "</td>";
                    echo "<td>" . $row['saturday_class'] . "</td>";
                    echo "<td>" . $row['sunday_class'] . "</td>";
                echo "</tr></tbody>";
            }
            echo "</table>";

            // Close result set
            mysqli_free_result($result);
        } else{
            echo "No records matching your query were found.";
        }
    } else{
        echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
    }

    // Close connection
    mysqli_close($link);
    ?>
    </html>

$(文档).ready(函数()
{
$(“表”).tablesorter();
}
);

我也有类似的问题。看起来这种风格也非常重要

我查看了示例的来源,例如,唯一缺少的是样式。 就我而言,我补充说:

< link href="http://mottie.github.io/tablesorter/css/theme.default.css" rel="stylesheet" >

只需在while循环之外添加和

 echo "</thead><tbody>";
            while($row = mysqli_fetch_array($result)){
                echo "<tr>";
                    echo "<td>" . $row['first_name'] . "</td>";
                    echo "<td>" . $row['last_name'] . "</td>";
                    echo "<td>" . $row['email_address'] . "</td>";
                    echo "<td>" . $row['ffid_num'] . "</td>";
                    echo "<td>" . $row['address_street'] . "</td>";
                    echo "<td>" . $row['address_city'] . "</td>";
                    echo "<td>" . $row['address_state'] . "</td>";
                    echo "<td>" . $row['address_zip'] . "</td>";
                    echo "<td>" . $row['fire_dept'] . "</td>";
                    echo "<td>" . $row['wants_tshirt'] . "</td>";
                    echo "<td>" . $row['shirt_size'] . "</td>";
                    echo "<td>" . $row['additional_shirts'] . "</td>";
                    echo "<td>" . $row['friday_class'] . "</td>";
                    echo "<td>" . $row['saturday_class'] . "</td>";
                    echo "<td>" . $row['sunday_class'] . "</td>";
                echo "</tr>";
            }
            echo "</tbody></table>";
echo”“;
while($row=mysqli\u fetch\u数组($result)){
回声“;
回显“$row['first_name']”;
回显“$row['last_name']”;
回显“$row['email_address']”;
回显“$row['ffid_num']”;
回音“$行[“地址街]”;
回音“$行[“地址城市]”;
回显“$row['address_state']”;
回显“$row['address_zip']”;
回声“$行[“消防部门]”;
回显“$row['wants_tshirt']”;
回声“$行[“衬衫尺寸]”;
回声“$row[“附加衬衫]”;
echo“$row['friday_class'”;
echo“$row['saturday_class'”;
echo“$row['sunday_class'”;
回声“;
}
回声“;

您能尝试将和置于while循环之外吗?我按照建议做了,但这并没有解决问题。这确实是正确的答案。做了这件事之后,这张桌子真是乱七八糟。只是没有样式,所以我直到点击标题才意识到它是可排序的。谢谢。@Kimcarona请添加您的评论作为答案,以便我可以对其进行投票:PYou正在将原始tablesorter中的css与我在“谢谢”中使用的css混合使用!我试着给你发消息,但由于某种原因没能。我希望你能回来,这样我就可以投票了!下一次我只会留下一个类似Mottie的评论。好吧,我应该把它作为答案发布,因为我第一次看到你的代码时就确定了。