JCD JCD - 27 days ago 5
MySQL Question

Saving Div's Array content to a MySQL database

I have table with input arrays and 1 div array. Of course i have no problem saving the input arrays to the database but when i do the same procedure for a div, its not working. When i view the column in the database, its blank.

<td><div name="partamount[]" id="partamount[]" class="amount" ></div> </td>


when you inspect the element:

Screenshot

PHP

$partamount = $_POST['partamount'];
$partamountarray = implode( ", ", $partamount);



$result = mysqli_query($mysqli, "INSERT INTO invoices(partamount, login_id) VALUES('$partamountarray', '$loginId')");

Answer

<div> elements are not form elements so they don't get passed. You should rather use some <input> element or use javascript to populate an <input type="hidden"> field with the same data as your <div> element have.