NAmeviolated Posted October 26, 2011 Share Posted October 26, 2011 Had some great help yesterday, but I'm stuck using <?php ?> on every line, thanks to Joomla Anyway, I'm trying to create a table, and it doesn't seem to be working, to create it, what is the correct format? <?php <table width='400px' border ='1'>; ?> ?? output will be put out on a per line within a if statement, which works, just the framing of the table and tr and td seem to be eluding me. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/ Share on other sites More sharing options...
voip03 Posted October 26, 2011 Share Posted October 26, 2011 <?php echo'<table width='750' border='1' cellspacing='0' cellpadding='1'> <tr> <td> This is my Table</td> </tr> </table>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/#findComment-1282313 Share on other sites More sharing options...
trq Posted October 26, 2011 Share Posted October 26, 2011 HTML doesn't mean anything to php, you need to put your html in a string, then echo that string. <?php echo "<table width='400px' border ='1'>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/#findComment-1282314 Share on other sites More sharing options...
Nodral Posted October 26, 2011 Share Posted October 26, 2011 Or alternatively come out of your <?php ?> tags and just put pure HTML in then reopen you tags as and when you need to. ie <?php /* Some php code defining variables, functions etc etc*/ ?> <table> <tr><td>blah blah <?php echo $variable ?> blah </td></tr> </table> <?php // more php code ?> Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/#findComment-1282318 Share on other sites More sharing options...
MasterACE14 Posted October 26, 2011 Share Posted October 26, 2011 or use the heredoc syntax: echo <<<TABLE <table width='750' border='1' cellspacing='0' cellpadding='1'> <tr> <td> This is my Table</td> </tr> </table> TABLE; Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/#findComment-1282319 Share on other sites More sharing options...
NAmeviolated Posted October 26, 2011 Author Share Posted October 26, 2011 HTML doesn't mean anything to php, you need to put your html in a string, then echo that string. <?php echo "<table width='400px' border ='1'>"; ?> Thanks, think this is what I'm after as I can't get outside the php brackets Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/#findComment-1282519 Share on other sites More sharing options...
khavelka20 Posted October 27, 2011 Share Posted October 27, 2011 @MasterAce preach on ! Heredoc is probably the single most useful tool in PHP!!!! Quote Link to comment https://forums.phpfreaks.com/topic/249823-correct-way-to-create-a-table-within/#findComment-1282572 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.