Displaying Custom Fields in a table
-
I’m not a developer and I know this code is UGLY, but I learn from piecing stuff together and I need your help. I finally figured out how to display my bulk discounts and I need to clean this code up, any suggestions?
1. It looks like this now, https://awesomescreenshot.com/0eb2lyon2b, I need to get rid of the list part, “x” out in red.
2. Suggestions on cleaning up the code?Thanks in advance.
<?php $bulkqty1 = get_post_meta($post->ID, '_bulkdiscount_quantity_1', false); $bulkdis1 = get_post_meta($post->ID, '_bulkdiscount_discount_1', false); $bulkqty2 = get_post_meta($post->ID, '_bulkdiscount_quantity_2', false); $bulkdis2 = get_post_meta($post->ID, '_bulkdiscount_discount_2', false); $bulkqty3 = get_post_meta($post->ID, '_bulkdiscount_quantity_3', false); $bulkdis3 = get_post_meta($post->ID, '_bulkdiscount_discount_3', false); $bulkqty4 = get_post_meta($post->ID, '_bulkdiscount_quantity_4', false); $bulkdis4 = get_post_meta($post->ID, '_bulkdiscount_discount_4', false); $bulkqty5 = get_post_meta($post->ID, '_bulkdiscount_quantity_5', false); $bulkdis5 = get_post_meta($post->ID, '_bulkdiscount_discount_5', false); foreach($bulkqty1 as $bulkqty1a) { echo '<li>'.$bulkqty1a.'</li>'; } foreach($bulkdis1 as $bulkdis1a) { echo '<li>'.$bulkdis1a.'</li>'; } foreach($bulkqty2 as $bulkqty2a) { echo '<li>'.$bulkqty1a.'</li>'; } foreach($bulkdis2 as $bulkdis2a) { echo '<li>'.$bulkdis1a.'</li>'; } foreach($bulkqty3 as $bulkqty3a) { echo '<li>'.$bulkqty1a.'</li>'; } foreach($bulkdis3 as $bulkdis3a) { echo '<li>'.$bulkdis1a.'</li>'; } foreach($bulkqty4 as $bulkqty4a) { echo '<li>'.$bulkqty1a.'</li>'; } foreach($bulkdis4 as $bulkdis4a) { echo '<li>'.$bulkdis1a.'</li>'; } foreach($bulkqty5 as $bulkqty5a) { echo '<li>'.$bulkqty1a.'</li>'; } foreach($bulkdis5 as $bulkdis5a) { echo '<li>'.$bulkdis1a.'</li>'; } echo '<table>'; echo '<tr>'; echo "<td>Quantity</td><td>$bulkqty1a</td><td>$bulkqty2a</td><td>$bulkqty3a</td><td>$bulkqty4a</td><td>$bulkqty5a</td>"; echo '</tr>'; echo '<tr>'; echo "<td>% Discount</td><td>$bulkdis1a</td><td>$bulkdis2a</td><td>$bulkdis3a</td><td>$bulkdis4a</td><td>$bulkdis5a</td>"; echo '</tr>'; echo '</table>'; ?>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Displaying Custom Fields in a table’ is closed to new replies.