I don’t want to post the PHP code yet because I really don’t think I have the best way of doing this.
Anyway here is what I am looking to accomplish.
I have a “classlist” table that has instructor led class information – including region and classtype.
I have “regions” table and a “classtype” table. Right now people are able to choose their region or classtype from a drop down – works great.
But they want the option to choose multiple regions and classtypes – and these have to be search/sortable. So when someone logs on they only see classes in their region by default.
I have created a helper table “regionhelper” that has fields – regionhelperid, regionid, and classlistid. I am able to add multiple regions to a class — works great.
But I would like the end-user to be able to see a select box with all of the regions and by them choosing 3 of the 12 regions they would update 3 rows on the regionhelper table. Right?
If my process behind this is right how do I update multiple rows at once on a different table?
You don’t have to have a region helper table to store the extra regions. You can comma separate the regions in the DB then use explode() to iterate over them and get each region. This saves the complexity of having multiple tables unnecessarily.
E.g Paris,Nairobi,Montevideo
To get the individual regions during data retrieval, you can simply use: