php echo tag not rendering my html code why?

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
imsoconfused
Forum Newbie
Posts: 15
Joined: Mon Oct 05, 2009 10:55 pm

php echo tag not rendering my html code why?

Post by imsoconfused »

Why isin't the html table rendering? I know I could just close the php tag and put the html after but i am working on something more complex that deals with this concept.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
 
<body>
<?php
echo "<table border="1">";
echo "<tr>";
echo "<td>row 1, cell 1</td>";
echo "<td>row 1, cell 2</td>";
echo "</tr>";
echo "<tr>";
echo "<td>row 2, cell 1</td>";
echo "<td>row 2, cell 2</td>";
echo "</tr>";
echo "</table>";
  
  
 ?>
 
</body>
</html>
veldthui
Forum Newbie
Posts: 10
Joined: Tue Oct 14, 2008 4:10 pm

Re: php echo tag not rendering my html code why?

Post by veldthui »

Have not checked this but would assume it is because of

echo "<table border="1">";

May be you should use

echo '<table border="1">';

or escape the " around the 1
imsoconfused
Forum Newbie
Posts: 15
Joined: Mon Oct 05, 2009 10:55 pm

Re: php echo tag not rendering my html code why?

Post by imsoconfused »

Awesome thanks,

Changing double quote to single quote is the answer

Code: Select all

echo '<table border="1">';
Post Reply