Skip to content
Advertisement

Duplicate checkbox remove in php

I have two tables named bookings and packages. Checked checkboxes are retrieved from bookings table and are working perfectly. But I also need unchecked check boxes from packages table. The problem is checked checkbox values display again.

Here is the display screenshot

JavaScript

Advertisement

Answer

You shouldn’t have two loops. You should only create the checkboxes from the package table. When you’re creating those checkboxes, add checked="checked" if the package name is in $split_pkg.

JavaScript

BTW, it’s not a good idea to to put comma-separated values in database columns. You should have a separate row for each booking. Then you would be able to join the two tables easily.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement