Questions tagged as 'foreach'

1
answer

Insert JSON file into the database via PHP

I have a JSON file that I need to insert the information contained in it into the database. JSON file: {"retorno":{"produtos":[{"produto":{"codigo":"AAAAAA","estoqueAtual":20}},{"produto":{"codigo":"BBBBBB","estoqueAtual":10}}]}} How I'm...
asked by 26.10.2017 / 21:38
1
answer

Accessing the Rasor variables inside a foreach

I'm trying to list the contents of a table, showing in each item the items of another table that maintains a relation with the first (1: N). For this I need 2 select, being the 2nd select based on each line of the result of the 1st select. The p...
asked by 06.09.2017 / 12:12
1
answer

Foreach with this type of JSON (PHP)

I'm trying to display the values of a JSON with PHP most unsuccessfully. Used Code: JSON: { "event_name": "offline_message", "widget_id": "sEcXk3TXEw", "visitor": { "name": "ARTULITO BARBOSA DE SOUSA", "email": "...
asked by 24.05.2017 / 15:50
1
answer

PHP for each with an if rule

I have a table that gives results of paid and unpaid commissions. I want it to only bring the paid, that is, if number_format($row->amount_paid,2) = 0 does not bring this line. <?php $i=-1; foreach($this->rows->r...
asked by 17.02.2017 / 15:10
1
answer

Duplicate items in Foreach

I have two Inputs ( curso[] and formacao[] ) html and when looping with foreach and starts to duplicate the items that are within the second foreach This is my class class Pessoa { private $Formacao; p...
asked by 09.01.2017 / 15:40
1
answer

Two foreachs php - Duplicate data

I have two selects that return two arrays and I need to go through them in the same table, but the records are being duplicated. How can I best resolve this issue? Follow the example: <?php foreach ($contratante...
asked by 26.11.2016 / 03:18
1
answer

Valid schedules

I have array with several times, sometimes having only 4 and sometimes N times. I need to get only a few records. Follow my code: $array = array( 0 => "08:00:00", 1 => "08:02:00", 2 => "08:04:00",...
asked by 21.09.2016 / 20:21
1
answer

How to code json with multiple objects in PHP

I need the following result: { "sala": [{ "horario": "18:30", "data": "Seg e Terça" }, { "horario": "10:30", "data": "Quarta Terça" }] }         UPDATE    I'm doing this in PHP:...
asked by 25.08.2016 / 14:09
1
answer

insert array foreach

I have a problem with entering data in the database with php, I have a form with several checkboxes, so I want to select more than 1 checkbox and insert it into the database, so I did form <input type="checkbox" name="f_carteira[]" value...
asked by 17.07.2016 / 18:59
1
answer

foreach with multiple variables

I'm trying a foreach with several variables got like? $record = array(); foreach($resultCustomers as $group) { $record[$group['CODIGO_CLIENTE'].$group['RAZAOSOCIAL']][] = $group['NOME']; } $output = array(); foreach( $record as...
asked by 11.07.2016 / 21:59