By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,807 Members | 1,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,807 IT Pros & Developers. It's quick & easy.

print tables by php code

P: 37
hi, i am trying to get my code to print HTML tables and other html tags but i get error right from the begining when i print a table, where within it there are more tables and then i print my results from queries.


heres the code where it starts from
[PHP]print "<table cellpadding="0" cellspacing="0" border="0" align="center" >"[/PHP]

for some reasons it dont let me, any comments?
Jan 7 '08 #1
Share this Question
Share on Google+
4 Replies


shane3341436
P: 63
hi, i am trying to get my code to print HTML tables and other html tags but i get error right from the begining when i print a table, where within it there are more tables and then i print my results from queries.


heres the code where it starts from
[PHP]print "<table cellpadding="0" cellspacing="0" border="0" align="center" >"[/PHP]

for some reasons it dont let me, any comments?
If that is not the type mistake, you cannot use double quote like that
because print command displays the content enclosed within either the pair of double quotes or a pair of single quotes.
You should use
[PHP]print '<table cellpadding="0" cellspacing="0" border="0" align="center" >';[/PHP]
Jan 7 '08 #2

P: 37
If that is not the type mistake, you cannot use double quote like that
because print command displays the content enclosed within either the pair of double quotes or a pair of single quotes.
You should use
[PHP]print '<table cellpadding="0" cellspacing="0" border="0" align="center" >';[/PHP]

thanks...it works, i also tried it like this
[PHP]print "<table cellpadding='0' cellspacing='0' border='0' align='center' >";[/PHP]

whats the differene between them?
Jan 7 '08 #3

Markus
Expert 5K+
P: 6,050
Think of quotes as brackets..

eg this is the beggining bracket ( this is the closing bracket )
this is the opening quote " this is the closing quote "

PHP can't tell which quote is closing what so it goes for the first two.

i.e
[php]
$string = "String opened... string closed";
$string = "String opened... quote within string " string closed"; ("
/*the quote within the string will be seen as the closing quote for the opening one.*/
/*however, if we were to use different types of quotes...*/
$string = "string opened... 'quote within string ' string closed";
//the single quote would not close the initial quote
//you can escape quotes with a backslash \
$string "string opened... quote within string \" string closed";
//the quote was escaped and therefore doesnt closer the initial quote
[/php]
Jan 7 '08 #4

P: 11
Expand|Select|Wrap|Line Numbers
  1. echo $var; // Results in the value of $var being printed
  2. echo '$var'; // Results in the word '$var'
  3. echo "$var"; // Results in the value of $var being printed
  4.  
Source

With doubles quotes (") you can print things like:
Expand|Select|Wrap|Line Numbers
  1. $name = 'spudse';
  2. echo "My name is $name";
  3.  
With single quotes you need to do this like this:
Expand|Select|Wrap|Line Numbers
  1. $name = 'spudse';
  2. echo 'My name is ' . $name;
  3.  
Also, some special characters, like newlines \n are printed as newline when encapsulated by double quotes and as characters when encapsulated by single quotes.
Jan 7 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.