I have an HTML table and a button that allows the user to add multiple rows.
<table id="component_table">
<thead>
<tr>
<th>Component</th>
<th>Component Type</th>
<th>Component Thickness</th>
</tr>
</thead>
<tbody id="component_tb">
<tr>
<td><?php echo $roofComponentDropDown ?></td>
<td><?php echo $roofComponentTypeDropDown ?></td>
<td><input id="component_thickness" name="component_thickness" type="text"></td>
</tr>
</tbody>
</table>
<input type="button" value="+" id="addRows" />
These are my drop downs that are being generated for the table
//Queries here to get data for the drop down lists that make up the roof construction table...
$roofComponentQuery = "SELECT * FROM roof_component";
$roofComponentData = mysqli_query($dbc, $roofComponentQuery);
while ($rcRow = mysqli_fetch_array($roofComponentData)) {
$roofComponentOptions .="<option value=\"".$rcRow['roof_component_id']."\">" . $rcRow['roof_component_name'] . "</option>";
}
$roofComponentDropDown = "<select name='selectedRoofComponent' id='selectedRoofComponent' onChange='getComponentType(this)'>
<option selected='selected' disabled='disabled' value=''>Select Component</option>
" . $roofComponentOptions . "
</select></br>";
$roofComponentTypeDropDown = "<select name='selectedComponentType' id='selectedComponentType'>
<option class='toggle_control' selected='selected' disabled='disabled' value=''>Select Type</option>
</select></br>";
Is there a way to add each <tr> into an array, then iterate through the array with a foreach loop and insert each <tr> into the DB?
Something like this maybe?
$tableRow = array();
foreach ($tableRow as $row) {
//insert query
}