Jump to content

Does this table coding make sense


stbalaji2u

Recommended Posts

Hi friends

whats the problem with this table tag which i used to embed in my php coding is the problem is with doule quotes ???

echo "<table border="0">
			<tr><td>id:</td>
			<td>$row[id]</td>
			</tr>
			<tr><td>Name:</td>
			<td>$row[name]</td>
			</tr>
			<tr><td>Comment:</td>
			<td>$row[com]</td>
			</tr>
			</table>";

Link to comment
https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/
Share on other sites

corbin is right.  You should use singles for the echo and double quotes for the attributes.

 

Try this:

 

echo '</pre>
<table border="0">
id:
 ' . $row[id] . ' 

Name:
 ' . $row[name] . ' 

Comment:
 ' . $row[com] . '

</ta

 

This is not tested but I think it's right.  You need to concatenate the php variables to the string or else they would be read in as HTML text.

While we're at it, you shouldn't use un-quoted strings to access arrays unless you mean to use constants.

 

Any un-quoted (if you know what I mean) string is interpreted as a constant, then, if a constant isn't found, it's used literally.

 

So, $row[id] for example should be $row['id'] or $row["id"].  (I would go with single quotes, but that's just a habit.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.