I have the following controller that works fine if "yes" is selected but is causing me some trouble if "no" is selected.
How could I make it insert "no" into the db?**
** I have added the elseif in trying to get it to say NO!
Controller:
//Dropdown Placeholder
$dropdown = $this->input->post('add_fields_placeholder', TRUE);
$dropdown = '';
if($dropdown = 'yes')
{
$dropdown_value = $this->input->post('add_fields_placeholderValue', TRUE);
}else($dropdown = 'no')
{
}
View:
<label for="add_fields_placeholder">Placeholder: </label>
<select name="add_fields_placeholder" id="add_fields_placeholder">
<option value="">Please Select</option>
<option value="yes" <?php echo set_select('add_fields_placeholder','yes', ( !empty($placeholderType) && $placeholderType == "yes" ? TRUE : FALSE ));?>>Yes</option>
<option value="no" <?php echo set_select('add_fields_placeholder','no', ( !empty($placeholderType) && $placeholderType == "no" ? TRUE : FALSE ));?>>No</option>
</select>
Okay, first of all get rid of
$dropdown = '';
Because this resets your value, so it won't hold yes or no
Secondly, both
if($dropdown = 'yes')
else($dropdown = 'no')
Need to use == instead of =. = is used to asign a value to a variable, == is used to compare values.
Does it work after you've made those changed?
Edit: You can't use else, and then add another condition. You either need to just use
else {
or use else
if($dropdown == 'no') {
Edit: For clarity and information, what you're doing in your if's with the single = is not asking if it's equal to yes or no, you're making it equal, and asking if you were able to