Skip to main content
Topic: Multi Select and insert in DB (Read 1405 times) previous topic - next topic

Multi Select and insert in DB

Hi,

I am researching if PHPRad is a tool I can use for my clients. Till so far I am very pleased with the results. I have one question do. I can't seem to find a well explanation on how to implement multi select in a way that that It will be stored correct in the database.

For instance I have the following tables:

| id | vehicle |
| 1  | Car A   |
| 2  | Car B   |

For obvious reasons , I want to add more than one part to the car with the following table withe a foreign key like:

| id | part     | id_car |
| 1  |  wheel | 1        |
| 2  |  break | 1        |

I know how to do it by coding by hand, but I was wondering if there is a way to do it in PHPRad, There is a option to make a multi select box in the add view but I can not get it to work. I there am tutorial on this issue? I only can find one to one relation tutorials.

thanx,
Gr Strixs

Re: Multi Select and insert in DB

Reply #1
@strixs‍ You can't currently do that using PHPRad's multi-select. What you can do with PHPRad's multi-select is store the part names in the vehicle DB. e.g

| id | vehicle | parts |
| 1  | Car A   | wheel, break |
| 2  | Car B   | wheel |

Or since you can code, you can edit the Add Page as custom and write your custom code. You will see the custom checkbox in the Pages pane where the List, View, Add, Edit and Delete pages are displayed, all you have to do is check it and start writing your code.

Regards,
Willvin