-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.

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.