Skip to content
Advertisement

CI4 Inserting ID from selected Strings

I’m so tired of thinking how to solve this case. already search by internet and never solved. straight to the point

this is my Controller of Product.php

JavaScript

this is my Models Model_product.php

JavaScript

and this is my Views create.php

JavaScript

i want to insert new data from Controller Product function store. i’ve this problem, i cannot change string value into integer value for this

JavaScript

if you see in the create.php Views, there is $row[‘***_id’] for all three tables. and i want to grab that three ids into store.

and this is the Error shown:

JavaScript

Advertisement

Answer

thank you for helping me before. i found the answer. here is the correct code where i can get the cat_id, stat_id and sup_id.

in the View create.php change this code

JavaScript

into this

JavaScript

this mean you will get the cat_id value from the database, instead of cat_name. change the stat_name into stat_id, then sup_name into sup_id.

when all of that changed, you can insert the database with the correct id number when you selected the value from the dropdown box.

this is the answer of my problem, thank you for helping me.

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