Most voted "foreach" questions
Provides an easy way to iterate over vectors and matrices.
Learn more…324 questions
Sort by count of
-
0
votes1
answer84
viewsPHP: Group data without using group_by
Does anyone know how to group data without using group_by in consultation? I need every 10 loop results (foreach), create a div, that is, 10 records within each div, I don’t care about the values.…
-
0
votes1
answer186
viewsMount a result array of a php foreach
Hello! I am unable to mount an array with results from a foreach. Got and foreach foreach($Result as $Aluno): extract($Aluno); echo '<tr>'; echo "<td class='nome'>{$Nome}</td>";…
-
0
votes1
answer60
viewsPrint all images from another table without repeating the title
I have the two tables below table IMAGES id_imagens | diretorio_imagem | post_id 1 imagem1.jpg 1 2 imagem2.jpg 1 3 imagem3.jpg 1 4 imagem4.jpg 1 5 imagem5.jpg 2 6 imagem6.jpg 2 7 imagem7.jpg 2 8…
-
0
votes1
answer62
views -
0
votes0
answers108
viewsError grabbing array by Indice
I have this code and do not know why I return only the first character of the variable(exe: if the login contains the value Diego, print only D) The print_r that is there,I put to test the return…
-
0
votes0
answers120
viewsInsert an array with codeIgniter and ajax
Hello I am trying to insert an array, but in this case, you can insert multiple lines in db. How do I pass the data to codeIgniter: var productsData = []; $(".productRow").each(function(i){ var…
-
0
votes1
answer596
viewsPick up information from one foreach with another foreach
I have a mysql search that brings me the following array when using a foreach, I have another sql search that brings me all the fields of a table that in case are the same field names that are below…
-
0
votes1
answer42
views -
0
votes1
answer37
viewsAction after the end of the foreach
Well, I have one foreach and would like to run some script right after it comes to an end. But how do I do this check? foreach ($array as $id_video) { $resultado = mysqli_query($conexao, "INSERT…
-
0
votes1
answer52
viewsIncrement an array with PHP foreach
I have a foreach that where I need to add the value of the variable to a array: foreach ($xml->NFe->infNFe->det as $itens){ $quantidade = round($itens->prod->qCom);…
-
0
votes2
answers120
viewsInner Join not returning database values
MY BANK CREATE TABLE EXPERIENCIA( exp_pri INT NOT NULL AUTO_INCREMENT, nome VARCHAR(150), email VARCHAR(50), exp VARCHAR(100), PRIMARY KEY(exp_pri) ); CREATE TABLE PRANCHA( prancha_pri INT NOT NULL…
-
0
votes0
answers63
viewsdata listing
he’s just printing the first line of the database and I want you to print out all the lines . <?php @session_start(); include_once $_SERVER['DOCUMENT_ROOT'] .…
-
0
votes1
answer35
viewsJavascript event repeats itself in other Ids
I wanted to make a Javascript if repeated in other screen components, in this example I am passing I did a foreach and inside it I put my javascript. the intention is that it repeated itself 10…
-
0
votes0
answers163
viewsPassing parameter inside the method in the foreach
I have the index that contains my class call CRUD and the foreach calling the class method crud. But within the foreach I’m trying to pass the table name parameter, but it shows nothing. If I take…
-
0
votes1
answer182
viewsForeach and multidimensional associative array with only one item
All right guys, I am facing a problem with foreach in PHP, in which I receive an xml and convert it to array. Only that in some cases xml has only one item (See the example below) <?xml…
-
0
votes1
answer1439
viewsPHP Read TXT, delete lines, create new file
I want to use PHP and xamp/wamp to do the following task on my computer without the need to upload/download: I have dozens of TXT files on the computer, each TXT containing only 1 name per line, no…
-
0
votes0
answers175
viewsHow to loop inside the foreach
I’m having a hard time getting the code to run. I have the variable $posts_metas which may be empty or have an array, depending on what the user has already registered in DB. I also have the…
-
0
votes2
answers387
views -
0
votes0
answers44
viewsforeach recording several times in the BD
Staff are making a product input form (NF mirror) that has the option to clone the lines to include more products. This form records in 2 tables 1st NF header and the 2nd saves the details where the…
-
0
votes1
answer514
viewsHow to send email simultaneously with Windows
I need my system to simultaneously send emails to all the emails in the comic book. Following the code below it only sends the first email from the list and still sends wrong. Sends to spam. And the…
-
0
votes0
answers33
viewsBest way to use Foreach
I have a bit of code, but I believe that is not one of the best, because I am beginner in programming. The values are coming duplicated, I would like to know if the way I am performing the code is…
-
0
votes0
answers257
viewsProblems with php foreach
I made a foreach with PHP and a file.json to simulate a mini shop inside a thumbnail in a slide carousel, however it is not properly appearing one side of the other as it should be. I would like to…
-
0
votes2
answers113
viewsPlay date returned from ajax in php foreach
I have an ajax search that picks up some data based on what was searched, how do I play this 'date' coming from an ajax in a foreach in php ? $.ajax({ headers: { 'X-CSRF-TOKEN':…
-
0
votes1
answer59
views -
0
votes1
answer721
viewsStore data set values in ASP.NET variables
I’m having trouble storing the return of a select in variables , I’m using a data set to create a table with the result of select , this select will return me some records and the form I’m making so…
-
0
votes1
answer109
viewsRegistration in foreach php
all right? I’m trying to register several entries in the comic according to the number of installments requested, but I’m not getting. My code: php: $Conn = parent::getConn(); try { foreach…
-
0
votes1
answer100
viewsList 3 tables in a drug dispensation?
I’m making a system for my pharmacy: dispensing prescription-controlled drugs. I made the table patients (id, name, Cpf, telephone, address, photo_document), dispensation (id_patient, id_medicament,…
-
0
votes1
answer60
viewsArrays in a single index
I made this question today, helped me a lot, now I have the code: foreach ($tokens as $row) { $token1[] = $row['oauth_token']; $token2[] = $row['oauth_token_secret']; } var_dump($token1);…
-
0
votes1
answer469
viewsHow do I show some elements of an array following this criterion?
I have to make a php form that at the end shows the price of each product purchased, showing only the prices of the products that in the other column of the table, were marked in the checkbox: FORM:…
-
0
votes1
answer253
viewsHow to paginate a foreach of a file_get_contents?
I am consulting an API that provides me data formatted in JSON, I collect it through file_get_contents and then print all the values using a foreach. However there are many values, more than 5,000…
-
0
votes1
answer1426
viewsForeach inside another array in php
How can I generate with php this array to make a payment transaction by Pagseguro? $params = array( 'email' => $PAGSEGURO_EMAIL, 'token' => $PAGSEGURO_TOKEN, 'creditCardToken' =>…
-
0
votes2
answers1613
viewsPlace two Arrays inside a foreach
Well, in case I have two arrays that are received from inputs, based on renting rooms from a hotel, in case each room needs to display number of adults and children, I got help from someone here in…
-
0
votes1
answer53
viewsPHP break list items "<li>" into variables to add in MYSQL table
I have a form with <textarea> with the following value: <textarea id="lista-ingredientes" name="lista-ingredientes"> <ul> <li>sal</li> <li>pimenta</li>…
-
0
votes2
answers622
views -
0
votes0
answers136
viewsError with array passing in foreach
function preencherJason() { document.getElementById('json_prod').value = ''; var arrayProduto = []; var table = $('#products_table'); table.find('tr').each(function() { var nodesTd =…
-
0
votes3
answers285
viewsCompare and replace Intel array
The problem and the following, I am creating daily OS chart, only that comes from the bank with day in English, I would like to replace each index with the value in Portuguese My code public…
-
0
votes0
answers33
viewsGenerate auto-sequence of the api when you click on the specific product
I have a customer portal, and in this customer portal will have a page of "my purchases" there will show the products purchased, and when you click on it will appear the "tracking" of this product…
-
0
votes3
answers682
viewsSum of an array and PHP value concatenation
I have a dynamic array, it contains duplicate keys (TAG): [0] => Array ( [0] => Array ( [tag] => 5x1 Acessori Kids [pedido] => 6701622409 [quantidade] => 2125 ) ) [1] => Array (…
-
0
votes0
answers107
viewsForeach in PHP with Simplexmlelement Object
I need to have access to the information (id_midia, midia_tipo, etc.) within the object array below. How should I proceed? [midias] => SimpleXMLElement Object ( [midia] => SimpleXMLElement…
-
0
votes1
answer4499
viewsJava/JSTL - Table listing with c:foreach
I tried to list database information on a page JSP by means of the tag <c:forEach> but I’m not getting any return value. Bookoid: @Override public List<Livro> consultar() throws…
-
0
votes3
answers1186
viewsHow to check each character of an array? Javascript
Person, I’m with this code: const arrayOne = ['jean','geleia','gean','ea games', 'e1']; function buscar(){ arrayOne.forEach(function(valor){ const teste1 =…
-
0
votes2
answers742
viewsHow to put paging in foreach that returns a JSON list with ajax
I call this function which returns me a list and populates a table in the view, updating every time I pass a parameter through the filter. Everything works perfectly, just need to put paging,…
-
0
votes1
answer102
views(JAVA) Error in foreach
Why is there an error in executing the code below if I remove the break? The value of Arraylist clients is not updated every time it ends? for (Cliente cliente : clientes) { if…
-
0
votes2
answers250
viewsHow to sort and list only 5 items from a list?
You see, I am developing the Dashboard of a web system, in one of the filters I should list the 5 main customers and sort them by higher value of the sums of total of issued bills. I’m already able…
-
0
votes1
answer50
viewsFilling missing result index of a select with 0
I make a select in the database from which I get a array data. With this, I do the following foreach in the same: foreach ($resultado4 as $key => $value7) { $array6[$value7['carteira'].'flores']…
-
0
votes1
answer251
viewsLaravel: Problem with foreach
public function extract(){ $occupation = Occupation::join('invoices', 'occupations.id', '=', 'invoices.occupation_id') ->leftJoin('payments', 'invoices.id', '=', 'payments.invoice_id')…
-
0
votes1
answer134
viewsHow to "merge" foreach results
I have a script to upload multiple files in php. Then when uploading, I wanted him to insert in the table photos, the information with the names in this format: "name1.jpg|Nome2.jpg". The query I…
-
0
votes1
answer286
viewsVBA Module that stores data from one cell and moves it to another cell and moves to the bottom cell
Good evening guys, I created a folder with macro where I have two spreadsheets, Query and games. In the spreadsheet games I put name of games and their respective values in real, already in the…
-
0
votes1
answer91
viewsPicking indexes with equal keys from a non-associative array
How do I pick/group indexes with equal keys of an array, example: Array ( [field_label] => Array ( [0] => Texto [1] => Checkbox [2] => URL ) [field_type] => Array ( [0] => text [1]…
-
0
votes0
answers33
viewsHow to do this foreach to get news?
I have a link that I believe is an API, and I need to pick up the news (as if it were a feed) but I’ve done several foreach I can’t associate to bring the text I want inside PHP, follows the link…