shadiadiph Posted January 16, 2009 Share Posted January 16, 2009 I have a section which the value is definately Yes in the database but it keeps showing No as the selected value I already did a print $clientview; value statement to make sure the value is Yes. butthe select part isn't working isn't looks fine to me?? <? $clientview = $row["clientview"]; *// this is in the head the value is Yes // ?> <? if ($action == modify) { echo'<tr> <td id="t_clientview" class="head">CLIENT VIEW</td></tr> <tr> <td class="norm"> <select name="clientview" > <option value="No" if('.$clientview.'==No){selected}>No <option value="Yes" if('.$clientview.'==Yes){selected}>Yes </select> </td> </tr>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/ Share on other sites More sharing options...
Zephyr_Pure Posted January 16, 2009 Share Posted January 16, 2009 Break up your code some... so you can see what you're echo'ing and what you're not. Instead of the above, do this: <?php if ($action == modify) { ?> <!-- HTML HERE --> <?php } ?> ... and for checking the selected part (as an example), do: <option value="No" <?php if($clientview=='No'){echo 'selected'; }?>>No</option> Quote Link to comment https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/#findComment-738312 Share on other sites More sharing options...
abdfahim Posted January 16, 2009 Share Posted January 16, 2009 how can you use IF statement inside echo? Quote Link to comment https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/#findComment-738313 Share on other sites More sharing options...
abdfahim Posted January 16, 2009 Share Posted January 16, 2009 i change li'l bit in ur code, try this <?php $clientview = "Yes"; if($action == modify) { echo"<tr><td id=\"t_clientview\" class=\"head\">CLIENT VIEW</td></tr> <tr> <td class=\"norm\"> <select name=\"clientview\" > <option value=\"No\""; if($clientview=="No"){echo "selected";} echo ">No <option value=\"Yes\""; if($clientview=="Yes"){echo "selected";} echo ">Yes </select> </td> </tr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/#findComment-738314 Share on other sites More sharing options...
shadiadiph Posted January 16, 2009 Author Share Posted January 16, 2009 thank you Quote Link to comment https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/#findComment-738323 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.