4
It is possible to use PHP within a field data-title
?
I have the following code:
<div id="grid" class="m-row shuffle--container shuffle--fluid">
<?
$result = $connection -> query("SELECT * FROM portfolio") or die($connection -> error);
while($row = $result -> fetch_array(MYSQLI_ASSOC)){
?>
<div class="col-md-3 col-sm-4 col-xs-12 m-col-md-3 picture-item"
data-groups='["<?=$row['portfolio_tipo']?>"]'
data-date-created="<?=$row['portfolio_data']?>"
data-title="<?=$row['portfolio_titulo']?>">
<div class="picture-item__inner">
The problem is that every field data-...
does not work with php inside. None of the attributes works.
This html code was working perfectly, after putting with php stopped working.
Do not work in what sense? Do not show the values? Because the situation you proposed I see no problem in being executed. Be sure to use php > 5.4, because <?= (simplifying echo) I believe is only from this version up, in case I’m not mistaken.
– Rafael Withoeft
Complementing the information on the short tag: http://programmers.stackexchange.com/questions/151661/is-it-bad-practice-to-use-tag-in-php
– Rafael Withoeft
just add a
echo
before the variable that "holds" the value you want to print– Richard Dias
I tested locally here and in Ideone with an array of any https://ideone.com/nINakE ... worked correctly. Make sure the dice aren’t empty?
– Lucas
Yes I am sure they are not empty, I am using the same variables elsewhere and it works, only those attributes are not working
– Márcio André
@Márcioandré You are with the configuration
short_open_tag
enabled for use<?=
?– Rafael Withoeft
yes I always use like this
– Márcio André