1

I need to get the data from JSON objects and echo them in a table. Anyone willing to help? In the smarty template file I have:

{$chart_array|@print_r}

and it prints the following:

{ d: 'Aug 07', a: 0, b: 0 },{ d: 'Aug 08', a: 0, b: 0 },{ d: 'Aug 09', a: 0, b: 0 },{ d: 'Aug 10', a: 0, b: 0 },{ d: 'Aug 11', a: 0, b: 0 },{ d: 'Aug 12', a: 0, b: 0 },{ d: 'Aug 13', a: 0, b: 0 },{ d: 'Aug 14', a: 0, b: 0 },{ d: 'Aug 15', a: 0, b: 0 },{ d: 'Aug 16', a: 0, b: 0 },{ d: 'Aug 17', a: 0, b: 0 },{ d: 'Aug 18', a: 0, b: 0 },{ d: 'Aug 19', a: 0, b: 0 },{ d: 'Aug 20', a: 0, b: 0 },{ d: 'Aug 21', a: 0, b: 0 },{ d: 'Aug 22', a: 0, b: 0 },{ d: 'Aug 23', a: 0, b: 0 },{ d: 'Aug 24', a: 0, b: 0 },{ d: 'Aug 25', a: 0, b: 0 },{ d: 'Aug 26', a: 0, b: 0 },{ d: 'Aug 27', a: 0, b: 0 },{ d: 'Aug 28', a: 0, b: 0 },{ d: 'Aug 29', a: 0, b: 0 },{ d: 'Aug 30', a: 0, b: 0 },{ d: 'Aug 31', a: 0, b: 0 },{ d: 'Sep 01', a: 0, b: 0 },{ d: 'Sep 02', a: 0, b: 0 },{ d: 'Sep 03', a: 0, b: 0 },{ d: 'Sep 04', a: 144, b: 3 },{ d: 'Sep 05', a: 221, b: 2 },1

I have to make a table with this data where d is date a is visits and b is sales like so. How should I pull the data from $chart_array for a table like this?

            <table id='dyntable_payment_history'  class="table table-bordered table-hover tc-table">
                <thead>
                    <tr>
                        <th>Date</th>

                        <th>Clicks</th>

                        <th>Conversions</th>

                        <th>Sales Ratio</th>

                        <th>Earnings</th>
                    </tr>
                </thead>
                <tbody>
        <tr>
                        <td>Date Value</td>

                        <td>Clicks Value</td>

                        <td>Sales Value</td>

                        <td>Conversion Ratio (sales/clicks)%</td>

                        <td>Earnings Value</td>
        </tr>
                </tbody>
            </table>

I can't properly state the foreach statement for the <tr> element maybe. Please help!

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
lion
  • 97
  • 2
  • 13
  • Parse this data in the controller and assign it to the template. Don't parse in the template, if you can help it. – Brad Sep 05 '18 at 20:12
  • Hi, Brad! Thanks for your reply! I have to do it in the template. The php side is encoded and works with ioncube and I can't get the data elsewhere, except from $chart_array. – lion Sep 05 '18 at 20:16
  • Thats not valid JSON, as JSON does not allow single quoted strings or unquoted property names – RiggsFolly Sep 05 '18 at 22:30

0 Answers0