我真的很沮喪..我真的需要顯示這張表的權利。如何設置這個代碼來顯示錶垂直這樣的:PHP表數據顯示結果垂直不水平
1 - 4 - 7
2 - 5 - 8
3 - 6 - 9
而且不喜歡這樣的:
1 - 2 - 3 - 4
5 - 6 - 7 - 8
9 - ... E ct
<?php
$PNG_WEB_DIR = plugin_dir_path(__FILE__).'temp/';
wp_mkdir_p($PNG_WEB_DIR);
$cols = $this->settings['cols'];
$rows = $this->settings['rows'];
$label_number = 0;
// die($_GET['order_ids']);
$order_ids = explode(',',$_GET['ids']);
$order_count = count($order_ids);
$labels_per_page = $cols*$rows;
$page_count = ceil(($order_count)/$labels_per_page);
for ($page=0; $page < $page_count; $page++) {
echo '<table class="address-labels" width="100%" height="100%" border="0" cellpadding="0">';
$last_height = 0;
$current_height = $current_width = 0;
$current_row = 0;
for ($label=0; $label < $labels_per_page; $label++) {
$label_number++;
$current_col = (($label_number-1) % $cols)+1;
if ($current_col == 1) {
$last_height = $current_height;
$last_width = 0;
$current_row++;
echo '<tr class="label-row">';
}
if ($label_number > $this->offset && isset($order_ids[$label_number - $this->offset - 1])) {
$order_id = $order_ids[$label_number - $this->offset - 1];
} else {
$order_id = '';
}
$current_width = round($current_col * (100/$cols));
$width = $current_width - $last_width;
$last_width = $current_width;
$current_height = round($current_row * (100/$rows));
$height = $current_height - $last_height;
printf('<td width="%s%%" height="%s%%" class="label"><div class="label-wrapper">', $width, $height);
// because we are also looping through the empty labels,
// we need to check if there's an order for this label
if (!empty($order_id)) {
// get label data from order
$order = new WC_Order($order_id);
// replace placeholders
$label_data = isset($this->settings['address_data'])? nl2br($this->settings['address_data']): '[shipping_address]';
$label_data = $this->make_replacements($label_data, $order);
echo '<div class="address-block">';
echo '<div class="addrress_show">';
// process label template to display content
echo $label_data;
echo '</div>';
echo '<div class="clearb"></div>';
echo '</div>';
} else {
echo ' ';
}
echo '</div></td>';
if ($current_col == $cols) {
echo '</tr>';
}
}
echo '</table>';
}
// shpt_after_page hook
do_action('shpt_after_page');
?>
什麼是原始數據結構?一個數組數組 - 即:多維數組? – RamRaider
這是一個免費的WordPress插件的一部分https://wordpress.org/plugins/woocommerce-order-address-print/ 我希望它可以幫助你的問題,我是新的... –
不,這並沒有真正的幫助 – RamRaider