in Education by
This question already has answers here: How can I access an array/object? (6 answers) Closed 3 years ago. i have a form like this Macchina Dispositivo Descrizione OK NOK PARZ NA Note <?while($row = mysql_fetch_array($risultato)){ echo '<tr> '; $count ++; }?>
in the page "insert_controllo.php" if i print_r($_POST); i can see all the variable in the right way <!-- POST: Array ( [elements] => Array ( [0] => Array ( [macc] => 09 ) [1] => Array ( [iddispsic] => 8 [macc] => 09 [descgen] => Comandi di emergenza [chk1] => Array ( [0] => OK ) [note] => )...... i'm trying to retrieve the variable like this for($i=0; $i<count($_POST['elements']); $i++){ $macc = $_POST['elements']['macc']; $dispsic = $_POST['elements']['iddispsic']; $descgen = $_POST['elements']['descgen']; $chk1 = $_POST['elements']['chk1']; $note = $_POST['elements']['note']; echo $macc; echo $dispsic; echo $descgen; echo $chk1; echo $note; var_dump($macc); } } but in the var_Dump i get only NULL value. i need to INSERT them in my DB table can someone help me? thanks a lot best regards JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Try a foreach loop foreach ($_POST['elements'] as $element) { $macc = $element['macc']; $dispsic = $$element['iddispsic']; $descgen = $element['descgen']; $chk1 = $element['chk1']; $note = $element['note']; } } The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. http://php.net/manual/en/control-structures.foreach.php

Related questions

0 votes
    This question already has answers here: How can I access an array/object? (6 answers) Closed 3 years ago. i have a ... print_r($_POST); i can see all the variable in the right way...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I need to take the users input from the select box for Allergen1 once an option is selected and the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 10, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How to remove the space between inline/inline-block elements? (41 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
...