Jump to content

Recommended Posts

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>';
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/141070-solved-selected-value-problem/
Share on other sites

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>

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>";
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.