Monday, 24 September 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;">Tec8</td>
    <td style="width: 25%; height: 21px;">  <input name="Technoloie[]" type="checkbox" value="2" /> </td>

    </tr>
    </tbody>
    </table>

Here is the SQL Table for this Checkbox:

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

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?



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

No comments:

Post a Comment