mardi 28 août 2018

Add multiple combined PHP form data from multiple foreign MSSQL tables to one primary table

I got for this example 7 checkboxes:

<table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>


<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"><strong>Technologie</strong></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;">Tec1</td>
<td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;">Tec2</td>
<td style="width: 25%; height: 21px;"><input name="Technoloie[]" type="checkbox" value="1" /></td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;">Tec3</td>
<td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;"Tec4</td>
<td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="1" /> </td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;">Tec5</td>
<td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;">Tec6</td>
<td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="1" /> </td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;">Tec7</td>
<td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="1" /> </td>
<td style="width: 25%; height: 21px;"></td>
</tr>
</tbody>
</table>

Here is the SQL Table for this Checkbox:

+--------+------+------+------+------+------+------+------+
| Tec_ID | Tec1 | Tec2 | Tec3 | Tec4 | Tec5 | Tec6 | Tec7 |
+--------+------+------+------+------+------+------+------+
|      1 |    1 |    0 |    0 |    0 |    1 |    0 |    0 |
|      2 |    1 |    0 |    0 |    0 |    0 |    1 |    0 |
|      3 |    1 |    0 |    0 |    0 |    0 |    0 |    1 |
|      4 |    1 |    1 |    1 |    0 |    1 |    0 |    0 |
|      5 |    1 |    1 |    1 |    0 |    0 |    1 |    0 |
|      6 |    1 |    1 |    1 |    0 |    0 |    0 |    1 |
|      7 |    0 |    0 |    0 |    1 |    0 |    0 |    0 |
|      8 |    0 |    1 |    1 |    0 |    1 |    0 |    0 |
|      9 |    0 |    1 |    1 |    0 |    0 |    1 |    0 |
|     10 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
+--------+------+------+------+------+------+------+------+

You see already if I check Tec1 and Tec5, I want to get Tec_ID 1, so I need a combined checkbox select to get the right ID and I want to Insert this Primary Key as an foreign key into a other table to handle with the id in further functions.

But atm I have no idea, how I can handle this in MSSQL and PHP Code? Can someone help?




Aucun commentaire:

Enregistrer un commentaire