Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass multiple values to insert statement from dynamic number of html textboxs?
    primarykey
    data
    text
    <p>I am doing a project in which as per number getting by GET method, I display dynamic number of HTML Textbox for storing Multiple values. I am giving each textbox unique name+id in ascending manner starting from 1(Like textbox1,textbox2). Now I want that when I click on submit button, it should fire an insert statement which insert all textbox values at once. I know I can do by array, but my question is that how to get all textbox's value in an array and How to perform insert statement?</p> <p><strong>I have done following code:</strong></p> <p>Here is PHP Code for submit button:</p> <pre><code> $schedules = array(); if(isset($_POST['submit'])) { for($d=1; $d&lt;=$_GET['totalDay'] ;$d++) { array_push($schedules,$_POST['txtSchedule'.'$d']); } print_r($schedules); } </code></pre> <p>Here is the html code:</p> <pre><code>&lt;form method="post"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Day&lt;/td&gt; &lt;td&gt;Schedule&lt;/td&gt; &lt;/tr&gt; &lt;?php if(isset($_GET['tour_code']) and ($_GET['totalDay']!=1)) { $tour_code = $_GET['tour_code']; $total = $_GET['totalDay']; $i=0; do { $i=$i+1; ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $i;?&gt;&lt;/td&gt; &lt;td&gt; &lt;input name="txtSchedule&lt;?php echo $i;?&gt;" type="text" size="30"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php $start = date('Y-m-j',strtotime($start.'+1 days')); }while($i!=$total); } ?&gt; &lt;/table&gt; &lt;input type="submit" name="submit" value="Add Tour Details" /&gt; </code></pre> <p><strong>But I am getting an empty array.</strong> Note: $total is coming through URLString's $GET method.</p> <p>Below is the output of HTML: <img src="https://i.stack.imgur.com/iadPO.jpg" alt="enter image description here"></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