Welcome Guest, Not a member yet? Register   Sign In
Display Saved Database Answers in Form Issue
#10

[eluser]CroNiX[/eluser]
You can do that several ways.

1) have separate create/edit forms. A create form wouldn't have those default values coming from the db, so you would just set the default values in that case.
2) when setting the values, test if the variable exists, if it doesn't set another default value, like an empty string or the first value of a select.
3) when pulling data from the db, check to see if you actually got results (meaning the person exists), if not, set up an array of your default values.
For #3, something like:
Code:
$results = $this->profile_model->get_profile();
if (count($results) == 0)
{
  $results = array(
    'first_name' => '',
    'last_name'  => '',
    'birth_year' => 0 //(to select the default value that has a key of 0 in your dropdown array, assuming you have a key with 0 for your default)
  );
}

Theres probably more ways, but off the top of my head...


Messages In This Thread
Display Saved Database Answers in Form Issue - by El Forum - 06-11-2012, 04:02 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-11-2012, 06:09 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-11-2012, 02:29 PM
Display Saved Database Answers in Form Issue - by El Forum - 06-11-2012, 02:36 PM
Display Saved Database Answers in Form Issue - by El Forum - 06-11-2012, 06:27 PM
Display Saved Database Answers in Form Issue - by El Forum - 06-11-2012, 06:58 PM
Display Saved Database Answers in Form Issue - by El Forum - 06-12-2012, 03:52 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-12-2012, 07:06 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-12-2012, 09:54 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-12-2012, 10:03 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-12-2012, 11:46 AM
Display Saved Database Answers in Form Issue - by El Forum - 06-12-2012, 07:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB