{"id":4781174,"date":"2014-04-06T22:47:18","date_gmt":"2014-04-06T22:47:18","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/displaying-custom-fields-in-a-table\/"},"modified":"2016-08-21T19:04:19","modified_gmt":"2016-08-21T19:04:19","slug":"displaying-custom-fields-in-a-table","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/displaying-custom-fields-in-a-table\/","title":{"rendered":"Displaying Custom Fields in a table"},"content":{"rendered":"<p>I&#8217;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?<br \/>\n1. It looks like this now, http:\/\/awesomescreenshot.com\/0eb2lyon2b, I need to get rid of the list part, &#8220;x&#8221; out in red.<br \/>\n2. Suggestions on cleaning up the code?<\/p>\n<p>Thanks in advance.<\/p>\n<pre><code>&lt;?php\n\t\t\t\t\t$bulkqty1 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_quantity_1&#039;, false);\n\t\t\t\t\t$bulkdis1 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_discount_1&#039;, false);\n\t\t\t\t\t$bulkqty2 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_quantity_2&#039;, false);\n\t\t\t\t\t$bulkdis2 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_discount_2&#039;, false);\n\t\t\t\t\t$bulkqty3 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_quantity_3&#039;, false);\n\t\t\t\t\t$bulkdis3 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_discount_3&#039;, false);\n\t\t\t\t\t$bulkqty4 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_quantity_4&#039;, false);\n\t\t\t\t\t$bulkdis4 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_discount_4&#039;, false);\n\t\t\t\t\t$bulkqty5 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_quantity_5&#039;, false);\n\t\t\t\t\t$bulkdis5 = get_post_meta($post-&gt;ID, &#039;_bulkdiscount_discount_5&#039;, false);\n\n\t\t\t\t\tforeach($bulkqty1 as $bulkqty1a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkqty1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkdis1 as $bulkdis1a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkdis1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkqty2 as $bulkqty2a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkqty1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkdis2 as $bulkdis2a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkdis1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkqty3 as $bulkqty3a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkqty1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkdis3 as $bulkdis3a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkdis1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkqty4 as $bulkqty4a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkqty1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkdis4 as $bulkdis4a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkdis1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkqty5 as $bulkqty5a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkqty1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\tforeach($bulkdis5 as $bulkdis5a) {\n\t\t\t\t\t\techo &#039;&lt;li&gt;&#039;.$bulkdis1a.&#039;&lt;\/li&gt;&#039;;\n\t\t\t\t\t\t}\n\t\t\t\t\techo &#039;&lt;table&gt;&#039;;\n\t\t\t\t\techo &#039;&lt;tr&gt;&#039;;\n\t\t\t\t\techo &quot;&lt;td&gt;Quantity&lt;\/td&gt;&lt;td&gt;$bulkqty1a&lt;\/td&gt;&lt;td&gt;$bulkqty2a&lt;\/td&gt;&lt;td&gt;$bulkqty3a&lt;\/td&gt;&lt;td&gt;$bulkqty4a&lt;\/td&gt;&lt;td&gt;$bulkqty5a&lt;\/td&gt;&quot;;\n\t\t\t\t\techo &#039;&lt;\/tr&gt;&#039;;\n\t\t\t\t\techo &#039;&lt;tr&gt;&#039;;\n\t\t\t\t\techo &quot;&lt;td&gt;% Discount&lt;\/td&gt;&lt;td&gt;$bulkdis1a&lt;\/td&gt;&lt;td&gt;$bulkdis2a&lt;\/td&gt;&lt;td&gt;$bulkdis3a&lt;\/td&gt;&lt;td&gt;$bulkdis4a&lt;\/td&gt;&lt;td&gt;$bulkdis5a&lt;\/td&gt;&quot;;\n\t\t\t\t\techo &#039;&lt;\/tr&gt;&#039;;\n\t\t\t\t\techo &#039;&lt;\/table&gt;&#039;;\n\t\t\t\t?&gt;<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-4781174","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4781174","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/4781174\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=4781174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}