Is it possible to post two separate values when an item is selected with the Select option?

Hello,

I am listing products from more than one table with the Select option
Product IDs in each table are not unique
I am posting the ID value of the selected product
How do I know which table the product is selected for?

<select name="urunler[]">
    <option>&nbsp;</option>
        <optgroup label="Çanak Antenler">
            <option value="3">OFSET ÇANAK ANTEN TAKIMI 97 CM</option>
            <option value="4">OFSET ÇANAK ANTEN TAKIMI 97 CM</option>
            <option value="5">OFSET ÇANAK ANTEN TAKIMI 120 CM</option>
            <option value="6">OFSET ÇANAK ANTEN TAKIMI 120 CM</option>
            <option value="7">MEGA SAÇ ÇANAK ANTEN TAKIMI 135 CM</option>
            <option value="8">MEGA SAÇ ÇANAK ANTEN TAKIMI 135 CM</option>
        </optgroup>
        <optgroup label="LNBler">
            <option value="1">ONE TOUCH LNB MDU5</option>
            <option value="2">QUATRO LNB </option>
            <option value="3">QUATRO LNB </option>
        </optgroup>
        <optgroup label="Kablolar">
            <option value="2">ANTEN KABLOSU RG 6 U/4</option>
            <option value="4">ANTEN KABLOSU RG 6 U/6</option>
        </optgroup>
        <optgroup label="F Konnektörler">
            <option value="1">F KONNEKTÖR SIKIŞTIRMALI RG 6 U/4</option>
            <option value="2">F KONNEKTÖR SIKIŞTIRMALI RG 6 U/6</option>
            <option value="5">F KONNEKTÖR SIKIŞTIRMALI RG 6 U/4</option>
            <option value="6">F KONNEKTÖR SIKIŞTIRMALI RG 6 U/6</option>
            <option value="7">F KONNEKTÖR SIKIŞTIRMALI RG 11</option>
        </optgroup>
</select>

This is your real problem. All the products should be in ONE table. Learn and implement “Database Normalization”.

I’ve looked at what “Database Normalization” is but it’s for advanced I think it’s too early for me

For now I would like to prefer a simpler way

I will try to solve the problem for now by adding the table name with a dash next to the ID Thank you

value="canakanten-5" as

Early is when you want the database design to be correct. It is the foundation of all the code you will write using it. If the DB is incorrect, so will all the code you write to work with it.

Normalizing the DB IS the simple way. If you don’t, all your code will be a hack and you will forever incur technical debt.

Sponsor our Newsletter | Privacy Policy | Terms of Service