-5

I am trying to insert HTML and PHP into a PHP variable, but a syntax error is thrown:

    $nestedData[] = $row["titulo_anuncio"];
    $nestedData[] = $row["texto_anuncio"];
    $nestedData[] = $row["fecha_anuncio"];
    $nestedData[] = <<<EOD
<div>
<a id="<?php echo $row['emp_id']; ?>" class="edit-link" href="#" title="Edit">
            <img src="edit.png" width="20px" />
            </a>
</div>
EOD;

The error is thrown at the last $nestedData[] variable.

mvasco
  • 4,965
  • 7
  • 59
  • 120

1 Answers1

1

Try this:

$nestedData[] = $row["titulo_anuncio"];
$nestedData[] = $row["texto_anuncio"];
$nestedData[] = $row["fecha_anuncio"];
$nestedData[] = <<<EOD
<div>
<a id="{$row['emp_id']}" class="edit-link" href="#" title="Edit">
        <img src="edit.png" width="20px" />
        </a>

EOD;

You can't echo $row['emp_id'] within a line defining a string.

theHands
  • 373
  • 1
  • 3
  • 8