Jump to content


Photo

help with syntax


  • Please log in to reply
2 replies to this topic

#1 ev66

ev66
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 10:52 PM

Im using this code below to place the value of $a into first cell of a table, what is the correct syntax so that i only have to use one echo statement ? tried all diff combinattions but cant get it.
Thanks

<body><?php echo '<table width="400" border="1">
  <tr>
    <td>'; echo $a; echo '&nbsp;</td>

    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
'
?>

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 August 2006 - 11:02 PM

Use HEREDOC:
<?php echo <<<HTML
<table width="400" border="1">
  <tr>
    <td>{$a}</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
HTML;
// DO NOT INDENT OR PUT ANYTHING ON THE LINE ABOVE
?>


Or use this, not the use of the concatenation operator (.)
<?php echo '<table width="400" border="1">
  <tr>
    <td>' . $a . '</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>'; ?>


#3 ev66

ev66
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 31 August 2006 - 11:35 PM

thanks wildteen88,
i used your 2nd example, works now. ta




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users