Note that there are some explanatory texts on larger screens.

plurals
  1. POSend Multiple Text Fields in Array in PHP
    primarykey
    data
    text
    <p>I have the following code in my file:</p> <pre><code>&lt;table width="100%" class="friends"&gt; &lt;tr&gt; &lt;th width="50%"&gt;Friends Name&lt;/th&gt; &lt;th&gt;Friends Email&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="text" name="friendname[]" id="friendname[]" class="validate[minSize[4]]" min="4" placeholder="John &amp;amp; Jane Doe" style="width:80%;" /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="friendemail[]" id="friendemail[]" class="validate[custom[email]]" min="4" placeholder="jandjdoe@example.com" style="width:80%;" /&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p></p> <p>And the following as my PHP Code:</p> <pre><code>if(!empty($_POST['friendname']) &amp;&amp; !empty($_POST['friendemail']) &amp;&amp; is_array($_POST['friendname']) &amp;&amp; is_array($_POST['friendemail']) &amp;&amp; count($_POST['friendname']) === count($_POST['friendemail'])) { $err[] = "Please enter in your friend's details."; } $name_array = $_POST['friendname']; $email_array = $_POST['friendemail']; for ($i = 0; $i &lt; count($name_array); $i++) { $name = $name_array[$i]; $email = $name_array[$i]; } </code></pre> <p>However my code isn't echoing anything.</p> <p>I got the code for the above from <a href="https://stackoverflow.com/questions/18156505/insert-multiple-fields-using-foreach-loop">insert multiple fields using foreach loop</a></p> <p>I have other fields inside my form and they work fine, but for some reason these don't. Does anyone know of a way to do what I'm looking for based on the code above? :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload