vendredi 23 février 2018

Conditional statement inside string inside php

I am trying to evaluate date[3] to determine selected option. All this is inside a php sql query. I am not able to find out an easy way to get a selected for the value returned in date[3] in my $options string variable.

<?php  //sql statement
    foreach( $db->query($sql) as $data ) {

        $options = "<select type='text' name='pagephone'  select id='pagephone' >
       <option value=''></option>
       <option ". if ($data[3] == 'vtext.com' ){ echo 'selected' };. " value='vtext.com'>Verizon Wireless</option>
       <option ". if ($data[3] == 'vmobl.com' ){ echo 'selected' };. " value='vmobl.com'>Virgin Mobile</option>
       <option ". if ($data[3] == 'sms.alltelwireless.com' ){ echo 'selected' };. " value='sms.alltelwireless.com'>Alltel</option>";
       ?>

Aucun commentaire:

Enregistrer un commentaire