0
My line 68 is like this.
<option value="0"<?php echo ($info['estado']=='0')?'selected="selected"';'';?>>Não Pago</option>
0
My line 68 is like this.
<option value="0"<?php echo ($info['estado']=='0')?'selected="selected"';'';?>>Não Pago</option>
1
As I can not test at this time by is on mobile, I will leave two options below:
Option 1:
<option value="0" <?php echo ($info['estado']=='0')?' selected ="selected"' : ''; ?>>Não Pago</option>
Option 2:
<?php
if($info['estado']=='0') $select = ' selected="selected"'; else $select = "";
?>
<option value="0"<?php echo $select; ?>>Não Pago</option>
Good luck!
In option 2, there was no gap between the value="0"
and the content of the variable $select
? In my reading, in case the comparison is true, it will come out value="0"selected="selected"
That’s no problem, but I edited it and put the space.
If my answer helped you, please mark as resolved.
0
I think that’s what you want:
<?php if ($info['estado']=='0') {?>
<option value="0" selected="selected">Não Pago</option>
<?php } else { ?>
<option value="0">Não Pago</option>
<?php } ?>
I believe that this solution that you have now presented is very verbose. I prefer a greater concision, less repetition... And also PHP offers a more user-friendly syntax for making these blocks in the middle of HTML, if (cond):
, else:
, endif
Thank you very much.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
Your question is very broad. But I will leave an answer.
– user41630
You put a
;
in the ternary operator, but the ternary:
. Instead of writing?:
, you wrote?;
– Jefferson Quesado