Reply
Help with PHP/HTML Tables
Old 05-17-2008, 09:00 PM Help with PHP/HTML Tables
choskins102's Avatar
Super Talker

Posts: 124
Name: Casey
I am having problems getting a table the way that I want it. If I use HTML, I don't have any problems.

Code:
<table cellspacing="5" cellpadding="5" width="100%" border="1">
<tr><td>Info 1</td><td>Info 2</td></tr></table>

However, if I use the same code but wrap it around PHP tags, I start having problems.

Code:
<?php
echo "<table cellspacing='5' cellpadding='5' width='100%' border='1'>";
echo "<tr><td>Info 1</td><td>Info 2</td></tr></table>";
?>
The problem I am having is that the cellpadding does not show up when using PHP. Everything else works just like it should. Any suggestions?
choskins102 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-17-2008, 11:02 PM Re: Help with PHP/HTML Tables
evilhuman's Avatar
Junior Talker

Posts: 3
Name: Tom
That shouldn't make any different at all. Assuming you're not just crazy, or using some sort of whacked out browser no one else has heard of, I'm forced to suggest using single quotes for your echoes to allow you to use proper double quoted HTML without having to escape it.

PHP Code:
echo '<table cellspacing="5" cellpadding="5" width="100%" border="1">'
I don't think this will make any difference as I suspect there's something else affecting the style of the table here.

As an aside, single quotes are acceptable in PHP and if used appropriately give, tho utterly miniscule and only noticeable in BIG scripts, a slight server resource improvement over double quotes because PHP parses double quoted strings for variables - single quoted strings are used "as-is". Just FYI.
evilhuman is offline
Reply With Quote
View Public Profile Visit evilhuman's homepage!
 
Old 05-18-2008, 12:06 AM Re: Help with PHP/HTML Tables
nyef's Avatar
Ultra Talker

Posts: 264
Name: Lucas
I bet it's the single quotes.
Reversing the single/double quotes is the optimal solution.
As an aside, it's not proper html, but you can also just omit the quotes entirely and it will still display correctly on almost any browser.
Code:
<table cellspacing=5 cellpadding=5 width=100% border=1>...</table>
But then, if you want to do things the right way, you should be using CSS to modify the table's attributes rather than using the deprecated attribute tags:

Code:
<table style="margin:5px;padding:5px;width:100%;border:1px solid black;">...</table>
Or better yet, make those definitions in a separate css file and use a class or id to assign it to the table.

Last edited by nyef : 05-18-2008 at 12:08 AM.
nyef is offline
Reply With Quote
View Public Profile Visit nyef's homepage!
 
Old 05-20-2008, 07:45 PM Re: Help with PHP/HTML Tables
Super Talker

Posts: 123
Name: Nick Mallare
Quote:
Originally Posted by nyef View Post
I bet it's the single quotes.
Reversing the single/double quotes is the optimal solution.
As an aside, it's not proper html, but you can also just omit the quotes entirely and it will still display correctly on almost any browser.
Code:
<table cellspacing=5 cellpadding=5 width=100% border=1>...</table>
But then, if you want to do things the right way, you should be using CSS to modify the table's attributes rather than using the deprecated attribute tags:

Code:
<table style="margin:5px;padding:5px;width:100%;border:1px solid black;">...</table>
Or better yet, make those definitions in a separate css file and use a class or id to assign it to the table.
Better yet, don't use tables unless you are presenting tabular data.

Even better, if you are presenting tabular data, don't use tables at all, but rather look into stacking unordered lists on top of each other and use CSS to make it look pretty.

Nick
nmallare is offline
Reply With Quote
View Public Profile Visit nmallare's homepage!
 
Reply     « Reply to Help with PHP/HTML Tables
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12487 seconds with 12 queries