mardi 30 janvier 2018

displaying values from json file on a table on laravel

I am trying to display information from a json file to a table on blade template. the problem is, the value i need to display is a result of two values eg

@if($data['categoryOptionCombo'] == 'nehCW5s6Hx4') @else 0 @endif

{ "dataSet": "Hwcn7ajwZ1p", "completeDate": "", "orgUnit": "100097-5", "period": "2016Q4", "dataValues": [ { "dataElement": "G1Xh1qsVqKJ", "value": "244", "storedBy": "ctcUser", "timeStamp": "2017-01-04", "categoryOptionCombo": "YpFuX3wm6r8", "attributeOptionCombo": "uGIJ6IdkP7Q" }, { "dataElement": "G1Xh1qsVqKJ", "value": "339", "storedBy": "ctcUser", "timeStamp": "2017-01-04", "categoryOptionCombo": "Xns0ysCNhcv", "attributeOptionCombo": "uGIJ6IdkP7Q" }, { "dataElement": "G1Xh1qsVqKJ", "value": "5789", "storedBy": "ctcUser", "timeStamp": "2017-01-04", "categoryOptionCombo": "OKxxCNhyCrd", "attributeOptionCombo": "uGIJ6IdkP7Q" }, ... ] }

the table i want to display to:

`<table class="table table-bordered table-striped table-responsive">
   <thead>
    <tr>
       <th class="text-center">Indicator</th>
       <th class="text-center">Total</th>
       <th class="text-center" colspan="5">Males</th>
       <th class="text-center" colspan="5">Females</th>
    </tr>
    <tr>
       <th></th>
       <th></th>
       <th>Total</th>
       <th> < 1 year</th>
       <th> 1-4 years</th>
       <th> 5-14years</th>
       <th> > 15 years</th>
       <th>Total</th>
       <th> < 1 year</th>
       <th> 1-4 years</th>
       <th> 5-15 years</th>
       <th> > 15 years</th>
     </tr>
     <tr><th colspan="12"><b>HIV CARE (Pre ART and ART)</b></th></tr>                                            
   </thead>                                            
   <tbody>
     @foreach($json['dataValues'] as $data)
     <tr>
       <td># <b>1.1 Cumulative number of persons ever enrolled in care at this facility at beginning of the reporting quarter</b></td>
       <td>@if($data['value'] != '')  @else 0 @endif</td>
       <td></td>
       <td>@if($data['categoryOptionCombo'] == 'nehCW5s6Hx4')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'ttFf9vc6pnB')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'DNqn8VIZxhn')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'ZRSSGOzZeT0')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'IR5epaaFjxT')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'YpFuX3wm6r8')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'Oua3ZLWhBIg')  @else 0 @endif</td>
       <td>@if($data['categoryOptionCombo'] == 'z9VAozP1BEu')  @else 0 @endif</td>
      </tr>
   @endforeach
 </tbody>
</table>`

Currently i can pull values inside dataValues, but i cannot display the data on a single row, instead each data is being displayed on its own row:

this is how it displays now



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BGkIfm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire