How to insert corporate details into database |
Insert creates a new database record, update will update an existing record.
Delete will delete the record, replace will delete the record then insert it. PHP Code: $data = [ What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-20-2020, 04:31 PM)InsiteFX Wrote: Insert creates a new database record, update will update an existing record. OK, I understand that. I dont think replace is appropriate. The only one I need to use is "update" but I cant get it to work. I want to get the contents of $product placed into the temp_1 field of an existing record. I dont want the other fields of that record interfered with. If there is existing content within temp_1 then I want it to be overwritten. Currently, because Im dealing with a new field temp_1 is empty. And currently, Im entering into tbl_members, and later when Ive learnt how, I will do the same in tbl_corporate that Ive recently created. I have this in the Controller; PHP Code: $lcuser = $this->session->userdata('user_name'); And this in the Model; PHP Code: public function update_product($product) Everything else works except the entry into temp_1.
Try using set on the array.
PHP Code: public function update_product($product) What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-21-2020, 12:23 PM)InsiteFX Wrote: Try using set on the array. Would it help if the number of the column was included?
Show me you table structure with all column names etc.;
Also check to make sure you are getting the users name. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(11-21-2020, 02:38 PM)InsiteFX Wrote: Show me you table structure with all column names etc.; Here is the table structure. PHP Code: $data = array('user_id' => $result->user_id, 'date_reg' => $result->date_reg, 'user_name' => $result->user_name, 'pass_word' => $result->pass_word, 'first_name' => $result->first_name, 'last_name' => $result->last_name, 'country_territory' => $result->country_territory, 'temp_1' => $result->temp_1); The users name is derived from; PHP Code: $lcuser = $this->session->userdata('user_name'); And it works coz it appears in the view page that is the photos upload & triggers to send the $product to the database. I want to do the same in the data upload like this; PHP Code: $product = $this->session->userdata('temp_1'); By the way I retrieve the country_territory for the corporate table the same way. PHP Code: $countryterritory = $this->session->userdata('country_territory'); Ive learned how to get all the pages to redirect which is no longer the problem as it was before.
(11-21-2020, 02:38 PM)InsiteFX Wrote: Show me you table structure with all column names etc.; Ive found the problem. $user needs to be defined in the Model as follows; PHP Code: public function update_product($product)
(11-21-2020, 02:38 PM)InsiteFX Wrote: Show me you table structure with all column names etc.; Hey InsiteFX I have another problem. In the view page I have the following which works good. PHP Code: <?php echo $this->session->userdata('user_name'); ?> But if I have the following it wont work even though the field has data. PHP Code: <?php echo $this->session->userdata('temp_1'); ?> If I do the same for last_name it works. PHP Code: <?php echo $this->session->userdata('last_name'); ?> But if I change the column name in the table to last_temp & have the following it wont work. If I change both back to last_name it works. PHP Code: <?php echo $this->session->userdata('last_temp'); ?> Ive tried the following but makes no difference. PHP Code: <?php echo $this->session->set_userdata('temp_1'); ?> It appears that anything new wont work, whereas all existing data does work. Ive added temp_1 to the Login Controller & done a fresh Login. And Ive tried different names & tried deleting & reinserting new columns into the table. Have you any suggestions?
|
Welcome Guest, Not a member yet? Register Sign In |