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

前端 未结 6 1800
南方客
南方客 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条回答
  •  心在旅途
    2020-11-27 16:00

    This is the most simple solution that use:

    // Use this as first line upon load of page

    $sort = $_GET['s'];
    

    // Then simply sort according to that variable

    $sql="SELECT * FROM tracks ORDER BY $sort";
    
    echo '';
    echo 'Title';
    echo 'Album';
    echo 'Artist';
    echo 'Count';
    echo '';
    

提交回复
热议问题