ev66 Posted August 31, 2006 Share Posted August 31, 2006 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>[color=red]<?php[/color] [color=blue]echo '<table width="400" border="1"> <tr> <td>'; echo $a; echo ' </td>[/color] <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr></table>'[color=red]?>[/color] Quote Link to comment https://forums.phpfreaks.com/topic/19303-help-with-syntax/ Share on other sites More sharing options...
wildteen88 Posted August 31, 2006 Share Posted August 31, 2006 Use HEREDOC:[code=php:0]<?php echo <<<HTML<table width="400" border="1"> <tr> <td>{$a}</td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr></table>HTML;// DO NOT INDENT OR PUT ANYTHING ON THE LINE ABOVE?>[/code]Or use this, not the use of the concatenation operator (.)[code=php:0]<?php echo '<table width="400" border="1"> <tr> <td>' . $a . '</td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr></table>'; ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19303-help-with-syntax/#findComment-83730 Share on other sites More sharing options...
ev66 Posted August 31, 2006 Author Share Posted August 31, 2006 thanks wildteen88,i used your 2nd example, works now. ta Quote Link to comment https://forums.phpfreaks.com/topic/19303-help-with-syntax/#findComment-83749 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.