How to sort rows of HTML table that are called from MySQL

前端 未结 6 1786
南方客
南方客 2020-11-27 15:12

I know it\'s such a basic thing, but a Google search hasn\'t shown me how to re-sort the rows after clicking the th links.

I\'ve got this:



        
6条回答
  •  Happy的楠姐
    2020-11-27 16:08

    The easiest way to do this would be to put a link on your column headers, pointing to the same page. In the query string, put a variable so that you know what they clicked on, and then use ORDER BY in your SQL query to perform the ordering.

    The HTML would look like this:

    Type:
    Description:
    Recorded Date:
    Added Date:
    

    And in the php code, do something like this:

    
    

    Notice that you shouldn't take the $_GET value directly and append it to your query. As some user could got to MyPage.php?sort=; DELETE FROM MyTable;

提交回复
热议问题