Forum Moderators: coopster

Message Too Old, No Replies

php and tables.

a question about tables

         

JCphotog

2:10 am on Jul 19, 2007 (gmt 0)

10+ Year Member



Hi. I'm a bit new to coding in php. So I have several variables with a bit of HTML in each which i'm using echo to display. Instead of having them show up sequentially, I'd like to output them into a horizontal table side by side taking up half of a block in a php article with in a portal. I know you can put tables with in a variable, but how do you display multiple variables with in a table.

Any thoughts?

Here's an example.

$test1 = '<font color="#3300cc" size="4">some text</font><br><font size="3"><a href="/directory/index.php">linktext</a></font><br><br />';
echo $test1;

$test2 = "<br><font size='2'>more text<a href='/domain/index.php'>link text</a> some more text.</font><br />";
echo $test2;

in actuality my code is a bit more complex. A few variables contain code that will fetch images from another gallery script's database..

Thanks for the help!

--JC

phparion

11:23 am on Jul 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I guess you're also new to HTML and not php.

you need to run a loop, if required, otherwise simply make an html table and create as much cells as you need and then echo the variables in the cells.

also from your sample code i am guessing you are doing very bad coding practice. try to keep your styling separate from the data manipulation i.e use css instead of using so much fonts tags etc etc in your code.

external css can help you style it once and throughout the application!

JCphotog

1:22 pm on Jul 19, 2007 (gmt 0)

10+ Year Member



Thanks for the advice.

hawkerz

1:47 pm on Jul 19, 2007 (gmt 0)

10+ Year Member



or, you can get really clever and put it all into a MySQL db, and fetch the table as an array