我正在尝试使用PHP将sql值返回到HTML表中.除了最后一列“GROUP _ CONCAT(provision_id)”之外,我能够在没有问题的情况下填充每一列.
相关代码:
PHP
global $wpdb;
$wpdb->show_errors();
$contents = $wpdb->get_results( $wpdb->prepare("SELECT salaries.id,name,remaining,contract_value,GROUP_CONCAT( provision_id ) FROM salaries LEFT JOIN contracts ON contracts.id = salaries.id GROUP BY salaries.id"));
?>
[table header stuff...]
PHP
foreach ($contents as $content) {
?>
PHP echo $content->name ?>PHP echo $content->remaining ?>PHP echo $content->contract_value ?>PHP echo $content->GROUP_CONCAT(provision_id) ?>PHP }; ?>
只是回显$content-> provision-id也不起作用.
最佳答案
使用alias for the column.
原文链接:https://www.f2er.com/mysql/434055.htmlGROUP_CONCAT( provision_id ) as pids ... echo $content->pids