JCD JCD - 1 year ago 52
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:



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

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

Answer Source

<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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download