foreach

How do I insert multiple value if there is only one value in form

本秂侑毒 提交于 2020-02-08 02:58:29
问题 I need to know how can I insert or update a value in my DB for a invoice form if the value of the input that I need to save is only one time? I have a invoice form where I select a product in every row, and finally I have the input(user_id) with the value I need to save with the rest of the inputs Like per example, I choose in the invoice: 10 tomatoes 5 garlics 2 beans and finally there is my Id (user_id, not the Id of PRODUCTOS table that is unique) Id=1 Here is the schema of my table, and

How to loop only first value from checkbox with insert query

情到浓时终转凉″ 提交于 2020-02-07 01:27:39
问题 i have checkbox with two values like <input type="checkbox" name="analysis[]" value="'.$rows['name'].'_'.$rows['cost'].'"> i want loop only the first value (name) with insert query that is my code , working but it only insert one record every time . loop not working $allAnalysis = $_REQUEST['analysis']; foreach($allAnalysis as $analysis) { $analysis = explode("_", $analysis); $analysis_name = $analysis[0]; $analysis_insert = "INSERT INTO analysis ( analysis_id , analysis_name ) VALUES ( NULL

How to loop only first value from checkbox with insert query

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-07 01:24:05
问题 i have checkbox with two values like <input type="checkbox" name="analysis[]" value="'.$rows['name'].'_'.$rows['cost'].'"> i want loop only the first value (name) with insert query that is my code , working but it only insert one record every time . loop not working $allAnalysis = $_REQUEST['analysis']; foreach($allAnalysis as $analysis) { $analysis = explode("_", $analysis); $analysis_name = $analysis[0]; $analysis_insert = "INSERT INTO analysis ( analysis_id , analysis_name ) VALUES ( NULL

How to get Resharper to convert back to a foreach loop

妖精的绣舞 提交于 2020-02-03 03:46:06
问题 Resharper 5 can convert my foreach loops to Linq queries. Which I like. But linq is way way way harder to debug than a foreach loop. When I convert my foreach statement to a linq query, I don't see any option to go back the other way. Does any one know how to do this? Is it even possible? 回答1: We are working on LINQ2Foreach (and some other) functionality for ReSharper vNext 回答2: I do not believe this is possible. Certainly, it's not listed in the examples of Quick Fixes, where loop-to-LINQ

User defined types in arrays/collections and for each loops

无人久伴 提交于 2020-02-01 19:59:15
问题 VBA shows in a popup that i am not allowed to iterate through an array with user defined types. I wrote a bit of code and wonder how i can work around this. Here is a mini example that focusses on what i want to be able to do. Option Explicit Type Info source As String destination As String End Type Sub specialCopy() Dim target As Variant Dim AllTargets() As Info: AllTargets = SetAllTargets() For Each target In AllTargets CopyValues (target) Next End Sub Function SetAllTargets() As Info() Dim

php foreach wrap every 2 divs

﹥>﹥吖頭↗ 提交于 2020-01-30 11:22:26
问题 I need to wrap every 2 divs with another div for a project (a row) so it will look like: <div class="row"> <div> Item </div> <div> Item </div> </div> <div class="row"> <div> Item </div> <div> Item </div> </div> I have tried a few solutions but they dont work since the items coming in are odd (9 items). Here is what I had: <?php $count = 0; foreach ($contents as $content) { //var_dump($content); $books = $content["tags"]; $book_image = $content['content_image']; $book_desc = $content['content

php foreach wrap every 2 divs

谁说我不能喝 提交于 2020-01-30 11:22:12
问题 I need to wrap every 2 divs with another div for a project (a row) so it will look like: <div class="row"> <div> Item </div> <div> Item </div> </div> <div class="row"> <div> Item </div> <div> Item </div> </div> I have tried a few solutions but they dont work since the items coming in are odd (9 items). Here is what I had: <?php $count = 0; foreach ($contents as $content) { //var_dump($content); $books = $content["tags"]; $book_image = $content['content_image']; $book_desc = $content['content

preg_match() expects parameter 2 to be string, array given Error

非 Y 不嫁゛ 提交于 2020-01-30 09:01:51
问题 I'm trying to insert array but I'm getting error:- preg_match() expects parameter 2 to be string, array given My form below like : {!! Form::text('description[]',null,['class' => 'input-field input-sm','v-model'=>'row.description']) !!} {!! Form::text('log_time[]',null,['class' => 'input-field input-sm','v-model'=>'row.log_time']) !!} My controller store function : $this->validate($request, $this->rules); $data = array(); foreach($request->description as $key=>$value){ $data[]=[ 'description'

'for_each_n' is not a member of 'std' in C++17

柔情痞子 提交于 2020-01-29 17:40:43
问题 I have small piece of code for std::for_each_n loop. I tried running it on inbuilt Coliru compiler GCC C++17 using following command : g++ -std=c++1z -O2 -Wall -pedantic -pthread main.cpp && ./a.out But compiler give an error that " 'for_each_n' is not a member of 'std' ". My code is bellow which is copied from cppreference. #include <algorithm> #include <iostream> #include <vector> int main() { std::vector<int> ns{1, 2, 3, 4, 5}; for (auto n: ns) std::cout << n << ", "; std::cout << '\n';

Wrapping a div around every third item in a foreach loop PHP [closed]

北慕城南 提交于 2020-01-28 09:52:31
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . //set the array $info = array( 'andy' => 'blue', 'andrew' => 'black', 'mark' => 'green', 'jane' => 'orange', 'simon' => 'red', 'joan' => 'pink', 'sue' =>