[eluser]ralf0909[/eluser]
[quote author="Ellli" date="1306097626"]why are you updating table in database before form is submitted? I cant see any logic in it.
You can create two functions, one to get details from database and show it in form, and second one for actions after form is submitted. Or in one function use if statemant to decide if you wan't get details from database and show it, or just update it.
something like:
Code:
if($this->input->post('your_submit_name')){
//do stuff with submited fields
}else{
//get details from database
}
or use form_validation class where you can also validate user inputs.[/quote]
so what i need to do?
i want to show the form with old data inside (or near the fields, is the same), if i change data in the fields and click on submit button, new data will saved in the database.
i'm new to codeigniter and object oriented programming.
i tried the if command but it doesn't show anything, i'm doint it wrong.
i think the problem is the function to extract data, tell me if is correct:
in the model i use a select on the row with the user_id of the user, and then i use a get to retrieve data. then i save the data on a variable named $query and put a "return $query;" right?
what's the differencre from "return $query;" and "return $query->result();" ?