Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.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和shorty对表进行排序_Php_Mysql_Smarty_Formatting - Fatal编程技术网

使用php和shorty对表进行排序

使用php和shorty对表进行排序,php,mysql,smarty,formatting,Php,Mysql,Smarty,Formatting,我正在一个使用php和smarty的商业网站上做一些工作。现在我们有一张发票正在发送给订单部门,需要一种方法系统地查找货架上的物品 我已经设置了所有字段,但我不知道如何使用php对html表行进行排序。它使用for-each语句为每个已排序的项生成一行 有没有一种方法可以在php中使用smarty或不使用smarty的组合来实现这一点?我对它还是新手,任何帮助都将不胜感激 我找到了这个问题 $products = func_query("SELECT $sql_tbl[order_details

我正在一个使用php和smarty的商业网站上做一些工作。现在我们有一张发票正在发送给订单部门,需要一种方法系统地查找货架上的物品

我已经设置了所有字段,但我不知道如何使用php对html表行进行排序。它使用for-each语句为每个已排序的项生成一行

有没有一种方法可以在php中使用smarty或不使用smarty的组合来实现这一点?我对它还是新手,任何帮助都将不胜感激

我找到了这个问题

$products = func_query("SELECT $sql_tbl[order_details].itemid, $sql_tbl[products].*, $sql_tbl[products_lng_current].*, $sql_tbl[extra_field_values].value, $sql_tbl[order_details].*, IF($sql_tbl[products].productid IS NULL, 'Y', '') as is_deleted, IF($sql_tbl[order_details].product = '', $sql_tbl[products_lng_current].product, $sql_tbl[order_details].product) as product $fields FROM $sql_tbl[order_details] LEFT JOIN $sql_tbl[products] ON $sql_tbl[order_details].productid = $sql_tbl[products].productid LEFT JOIN $sql_tbl[products_lng_current] ON $sql_tbl[products_lng_current].productid=$sql_tbl[products].productid $join WHERE $sql_tbl[order_details].orderid='$orderid' ORDER BY $sql_tbl[extra_field_values].value desc); 

我按添加了订单,但它会破坏页面

这取决于您检索数据的方式。如果它来自数据库,您应该能够在查询中包含
orderby
子句,一切都会很好

如果做不到这一点,您会提到您是在
foreach
循环中输出的,因此数据可能已经存储在外部源的数组中。在这种情况下,您可以尝试阅读PHP函数

查看jQuery插件“DataTables”:


最后,如果您除了使用DOM之外别无选择,那么您可能希望签出“DataTables”。它是一个用于jQuery的插件,允许使用自定义算法对
元素进行排序(您可以指定用户可以按哪些字段进行排序等)。将其集成到现有Smarty模板中也不会太痛苦。

假设这些订单是从数据库检索的,你应该按照查询的
顺序按
对它们进行排序,而不是让PHP进行排序。我找到了查询,但当我按顺序进行排序时,它会破坏页面。我还补充了get原因。谢谢你的回复。你能提出你的疑问吗?按顺序添加
当然不会破坏任何东西-除非添加错误。如果这是整行的逐字副本,则缺少结尾
(请参见前面的
).A derp,谢谢。我刚刚上传了它。页面现在已填充,但该表不再添加产品行。这与
订购人
或原始问题无关;)