Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php和mysql对表进行排序_Php_Mysql_Sql_Sorting - Fatal编程技术网

使用php和mysql对表进行排序

使用php和mysql对表进行排序,php,mysql,sql,sorting,Php,Mysql,Sql,Sorting,我正在尝试对网页表上mysql表的结果进行排序。我已经在所需列上创建了按钮(升序和降序)。对于最初的数据组,它工作正常。但是,当我更改为其他数据组(例如不同的月份)时,它将重定向到初始结果页面,而不是更改的月份。我已经用PHP创建了这个。其中一个表头是: print " <th>"; print " Clientprint"; print " <form action=\"#\" method=\"POST\"><button type=\"su

我正在尝试对网页表上mysql表的结果进行排序。我已经在所需列上创建了按钮(升序和降序)。对于最初的数据组,它工作正常。但是,当我更改为其他数据组(例如不同的月份)时,它将重定向到初始结果页面,而不是更改的月份。我已经用PHP创建了这个。其中一个表头是:

print "  <th>";
    print " Clientprint";
    print "  <form action=\"#\" method=\"POST\"><button type=\"submit\" name=\"client_val\" value=\"ASC\" style=\"border:0; background:transparent\" /><img src=\"up-icon.png\" width=\"16\" height=\"16\"></button>";
    print "  <button type=\"submit\" name=\"client_val\" value=\"DESC\" style=\"border:0; background:transparent\" /><img src=\"down-icon.png\" width=\"16\" height=\"16\"></button></form>";
    print " </th>\n";
print”“;
打印“客户端打印”;
打印“”;
打印“”;
打印“\n”;

能否显示您正在使用的一些代码?我通过以下方式接收值:if(array_key_exists('client_val',$\u POST))$sort_num=$\u POST['client_val'];然后将值$sort_num发送到数据库,然后根据接收到的值进行排序:if(array_key_exists('client_val',$_POST)){if($sort_num=='DESC')$query.=“ORDER BY
client
DESC”;else$query.=“ORDER BY
client
”}我真的不明白你想做什么。请更好地解释一下。嗨,loko,我在每个列名下都创建了按钮(升序和降序),当我单击按钮时,它会将值ASC或DESC发送到表中的相应列,以便我可以按特定列“排序”。对于初始选择来说,它工作得很好。当我更改选择时,它将显示数据,但我无法对新数据进行排序。当我单击列名下的按钮时,它会将我重定向到初始数据页,在那里我可以进行排序。