table in php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sarjanajava
Forum Newbie
Posts: 3
Joined: Mon Dec 02, 2002 10:29 am

table in php?

Post by sarjanajava »

How to create a table in PHP . I saw so many website using a fancy and very attractive color for tables, especially this forum
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

To do a table completely in PHP you have to escape out certain characters. For Example

Code: Select all

<?phpecho "<table width="100%" border="0" cellpadding="4" cellspacing="0">"

?>
Or you just do a mix like me. I just

Code: Select all

<?php
// your php code here.
?>
<table width="180" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><? echo $user; ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<?
// the rest of your stuff here.
?>
Now the advantages of straight php is that you use less <? or ?>. But as I am still learning i forget to escape out characters.

As for the colors use a cascade stylesheet for that.
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

Post by cheatboy00 »

I create my tables in the php code, using echos and such, I find it eaiser. Though if you do ti this way, and you view the source than you'll see all the html in one line... which can be brutal to sort through unless you do this...

Code: Select all

<?php
echo "<table border="1" bgcolor="#FFFFFF">\r\n";
?>
Note the \r\n that basicly means new line. if you dont want your html to be on one line just add this at the end of each echo(or if you want you can use print).
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you want to change the colors of the tables then this is CSS and HTML attibutes not PHP.

For more info on CSS: http://www.w3schools.com/css/default.asp

Mac
Post Reply