Hey guys please help me with my code, I want to disable select drop down if $stat=a, this is my code. Thank You!

echo "<select name='name' id='name' 'if ($stat =='a'){ echo ('disabled');}'>";

echo "<select name='name' id='name' <?php if ($stat =='a'){ echo ('disabled');} ?> >";

I haven't actually tested that but the main point is you need the <?php ?> tags otherwise you're just going to echo out the if statement as text.

$disabled = $stat =='a' ? 'disabled' : '';
echo "<select name='name' id='name' $disabled>";

Gotcha, thank you... Can you please explain the 1st line of the code. Thank You!

if i may revised the code a bit, i think the second line code should be like this:

echo "<select name='name' id='name' ".$disabled.">";
Member Avatar

No fang. Simple Variables can be parsed within double quotes. There is no need to concatenate them.

i'll never write the code that way, i thought it will be read as string.
I'll try it. thank you