Note that there are some explanatory texts on larger screens.

plurals
  1. POSending array values to a mysql database table
    primarykey
    data
    text
    <p>I have a PHP file named with Set of HTML codes. The values for the textboxes are assigned and they prints as I needed.</p> <pre><code>&lt;? echo "&lt;html&gt;"; echo "&lt;body&gt;"; for($i=0; $i&lt;5;$i++){ echo "&lt;input name='C[]' value='$Texting[$i]' style='background-color:#D0A9F5;'&gt;&lt;/input&gt;"; } echo '&lt;input type="submit" value="Save The Table" name="G"&gt;&lt;/input&gt;' echo "&lt;/body&gt;"; echo "&lt;/html&gt;"; ?&gt; </code></pre> <p>And I need to store the values of the textboxes in an array and its to another PHP file in order to send the values to the database. This is a part of other PHP file.</p> <pre><code>&lt;? if(!empty($_POST['G'])){ for($i=0;$i&lt;sizeof($_POST['C']);$i++){ echo var_dump($_POST['C']); $Query="INSERT INTO Questions(Questions_ID,Question_Name) VALUES($i+1,'$_POST[C][$i]')"; if(!mysqli_query($con,$Query)){ die("&lt;script&gt;alert( \"Error: ". mysqli_error($con)."\");window.location.href='FormCreationTrial.php';&lt;/script&gt;"); </code></pre> <p>} }</p> <pre><code>} ?&gt; </code></pre> <p>This is the var_dump of the array. array(3) { [0]=> string(1) "A" [1]=> string(5) "Male2" [2]=> string(7) "Female2" } Notice: Array to string conversion in C:\xampp\htdocs\PHIS\FinalSubmissionOfTheFormPHP.php on line 19. When I'm trying to send the array one by one it gives me an error like ' Duplicate entry 'Array[0]' for key 'Question_Name_UNIQUE'.</p> <p>And This prints the size of the received array perfectly. I need to send those data to a table called 'questions. Keys of the array should be the primary key of the table named column ID and values of the array should go to questionType column of the table. How can I do this? could someone please give me a hint. </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