Welcome Guest, Not a member yet? Register   Sign In
How send mail the name country and not id?
#1

[eluser]amina[/eluser]
I have a depended select. I try to place in the view in option value rowz->name but if I place it does not take me go of cities too I try concant but it didn't work
My model:
Code:
function getCountry(){
return $this->db->query("SELECT * FROM  country order by name ASC");
    }
  
    function getCity($idcountry){
        
        $query="SELECT * FROM  cities  where id_country = ".$idcountry;
        
        $data=$this->db->query($query, $idcountry);
        
            if($data->num_rows()>0){
            $output="<option value=''>- Seleccione city-</option>";  
            foreach($data->result() as $item){
              $output.="<option value='".$item-&gt;id.'-'."$item->name'>".$item->name."</option>";  
            }
        }else{
           $output="not results";
        }
        echo $output;
    }

In the getCity I could concant the name city for send mail

My view:

Code:
<label for="f_country"class="label">Country</label>
<select name="country" id="country" class="input">
<option value='-1'></option>

&lt;?php foreach($dt_country->result() as $rowz): ?&gt;
<option value='&lt;?php echo $rowz-&gt;id;?&gt;'>&lt;?php echo $rowz-> name; ?&gt;</option>
&lt;?php endforeach; ?&gt;
</select>

<label for="f_city" class="label">City<span class="req">*</span></label>
&lt;?= form_error('city','<div class="error">', '</div>') ?&gt;
<select name="city" id="city" class="input"></select>
In my view I couldn't
Thanks
#2

[eluser]leela[/eluser]
you are using the space in $rowz->name after ->... This could be the reason
#3

[eluser]amina[/eluser]
thanks for response but it works fine. My problem is option value $rowz->id; that I can't concant $rowz->name
for that in the send mail appears the name country and not id_country.
#4

[eluser]CroNiX[/eluser]
Code:
$output .= '<option value="' . $item-&gt;id . '-' . $item-&gt;name . '">' . $item->name . '</option>';

Code:
<option value="&lt;?php echo $rowz-&gt;id; ?&gt;">&lt;?php echo $rowz->name; ?&gt;</option>
#5

[eluser]amina[/eluser]
thanks, but in the sended mail appears the id country and not the name of the country, for this line
Code:
<option value="&lt;?php echo $rowz-&gt;id; ?&gt;">&lt;?php echo $rowz->name; ?&gt;</option>

because in the option value I have $rowz->id, but if I change $rowz->name, don't work.
In this line works fine
Code:
$output .= '<option value="' . $item-&gt;id . '-' . $item-&gt;name . '">' . $item->name . '</option>';

I want to do the same in country
#6

[eluser]leela[/eluser]
just make a die there what are the values it is having so that you can find the reason
#7

[eluser]InsiteFX[/eluser]
Try this:
Code:
<option value="&lt;?php echo $rowz-&gt;id.'-'.$rowz-&gt;name; ?&gt;">&lt;?php echo $rowz->name; ?&gt;</option>

// or this:
&lt;?php echo '<option value="'.$rowz-&gt;id.'-'.$rowz-&gt;name.'">'.$rowz->name.'</option>'; ?&gt;
#8

[eluser]amina[/eluser]
thanks for response your solution works fantastic!!! Thankssssss




Theme © iAndrew 2016 - Forum software by © MyBB