stbalaji2u Posted August 15, 2008 Share Posted August 15, 2008 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/ Share on other sites More sharing options...
lonewolf217 Posted August 15, 2008 Share Posted August 15, 2008 you didn't escape your quotes echo "<table border=\"0\"> Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/#findComment-617300 Share on other sites More sharing options...
Fadion Posted August 16, 2008 Share Posted August 16, 2008 As escaping the quotes would result in an ugly code, add single quotes for the attribute values: echo "<table border='0'>"; Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/#findComment-617737 Share on other sites More sharing options...
corbin Posted August 16, 2008 Share Posted August 16, 2008 Isn't it an HTML standard to use double quotes around attribute values? Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/#findComment-617856 Share on other sites More sharing options...
Fadion Posted August 16, 2008 Share Posted August 16, 2008 Then use the other way around echo '<table border="0">'; Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/#findComment-617920 Share on other sites More sharing options...
Maq Posted August 18, 2008 Share Posted August 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/#findComment-619370 Share on other sites More sharing options...
corbin Posted August 19, 2008 Share Posted August 19, 2008 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.) Quote Link to comment https://forums.phpfreaks.com/topic/119817-does-this-table-coding-make-sense/#findComment-619781 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.