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
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.

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.