Page 1 of 1

nested table in php

Posted: Mon Jun 29, 2009 2:15 pm
by podarum
Is there a way I can nest a table into my php code..? for example I have a whole bunch of form variables brought into php and I want to be able to print them in a table , so that I can align them and font them and make them all fancy..

Re: nested table in php

Posted: Mon Jun 29, 2009 2:28 pm
by Christopher
Not sure what you mean "nest"? You can do either of these with PHP:

Code: Select all

<?php
echo "<table>
<tr>
<td>$var1</td>
<td>$var2</td>
</tr>
</table>";
?>
<table>
<tr>
<td><?php echo $var1; ?></td>
<td><?php echo $var2; ?></td>
</tr>
</table>

Re: nested table in php

Posted: Mon Jun 29, 2009 3:20 pm
by podarum
Thank you , this is what I'm looking for.. but what can I insert if I want it to look like this:

The contents of variable1 : Var1
Variable2 is made up of : Var2

Sort of like a 2x2 table?
And is there a way I can make Var1 have a font and Var2 a different font? Thank you.

Re: nested table in php

Posted: Mon Jun 29, 2009 4:23 pm
by Christopher
You would put things like font attributes into the HTML. Create a style sheet with classes for the table cells. It really has nothing to do with PHP. Look around the web for examples of controlling the font in HTML.