seco
seco

Reputation: 33

insert php code insode EOT

i want to export this table to a variable

$tbl=<<<EOT
<table cellspacing="0" cellpadding="1" border="1">
    <tr>
        <td rowspan="3">$res=mysql_query($sql);<br />COLSPAN 3</td>
        <td>COL 2 - ROW 1</td>
        <td>COL 3 - ROW 1</td>
    </tr>
    <tr>
        <td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br />text line<br />text line<br />text line<br />text line</td>
        <td>COL 3 - ROW 2</td>
    </tr>
    <tr>
       <td>COL 3 - ROW 3</td>
    </tr>

</table>
EOT;

but the following code appeared as text !!

=mysql_query();

Upvotes: 0

Views: 140

Answers (1)

putvande
putvande

Reputation: 15213

You can't use functions inside the EOT block.
You have to define a variable outside of it to use it inside the EOT block:

$res = mysql_query($sql);
$tbl=<<<EOT
    <table cellspacing="0" cellpadding="1" border="1">
        <tr>
            <td rowspan="3">$res<br/>COLSPAN 3</td>
            <td>COL 2 - ROW 1</td>
            <td>COL 3 - ROW 1</td>
        </tr>
        <tr>
            <td rowspan="2">COL 2 - ROW 2 - COLSPAN 2<br/>text line<br/>text line<br/>text line<br/>text line</td>
            <td>COL 3 - ROW 2</td>
        </tr>
        <tr>
            <td>COL 3 - ROW 3</td>
        </tr>

    </table>
EOT;

Upvotes: 1

Related Questions