Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 136
Name: Casey
Trades: 3
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
 
 
Register now for full access!
Old 05-18-2008, 12:02 AM Re: Help with PHP/HTML Tables
evilhuman's Avatar
Junior Talker

Posts: 3
Name: Tom
Trades: 0
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, 01:06 AM Re: Help with PHP/HTML Tables
nyef's Avatar
Ultra Talker

Posts: 265
Name: Lucas
Trades: 0
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 01:08 AM..
nyef is offline
Reply With Quote
View Public Profile Visit nyef's homepage!
 
Old 05-20-2008, 08:45 PM Re: Help with PHP/HTML Tables
Super Talker

Posts: 144
Name: Nick Mallare
Location: Olathe, KS
Trades: 0
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
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
nmallare is offline
Reply With Quote
View Public Profile Visit nmallare's homepage!
 
Reply     « Reply to Help with PHP/HTML Tables
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.13895 seconds with 12 queries