У меня есть таблица HTML и кнопка, которая позволяет пользователю добавлять несколько строк.Добавить данные таблицы HTML в MySQL DB
<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" />
Это мои падения спады, которые генерируются для таблицы
//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>";
Есть ли способ, чтобы добавить каждый <tr>
в массив, а затем перебрать массив с петлей Еогеаспа и вставить каждый <tr>
в БД?
Что-то вроде этого, может быть?
$tableRow = array();
foreach ($tableRow as $row) {
//insert query
}
У вас есть форму для отправки таблицы на PHP? – Barmar
@Barmar Да, таблица находится в форме с несколькими другими полями ввода. – Zoxac
Вам нужно будет предоставить дополнительную информацию, схему таблицы mysql и полный код PHP – perodriguezl