Here is how I am echoing back a ‘normal’ table cell in PHP:
Code:
echo "<tr>";
echo "<td>Some cell data</td>";
echo "</tr>\n";
Attempt to echo a button within a cell:
echo "<tr>";
echo "<td><form action="insertdata.php?page=add" method="post">
Username: <input type="text" name="username" >
<input type="submit" >
</form>
</td>";
echo "</tr>\n";
Thank you for any help, this is quite confusing to me. I am a beginner when it comes to PHP so please pardon any errors and feel free to kindly correct me wherever a correction is needed!
You need to either escape your double quotes
"that appear inside your string surrounded by double quotes, or use a different quote style (i.e. single quotes') to surround the string that contains the double quotes. It’s actually made quite obvious what the problem is by the syntax highlighting on this site.You could either do this:
…or this…
I suggest you read this thoroughly so you no what you can and can’t legally do with strings in PHP.
As a side note, it is a bad idea to put new-line literals inside quoted strings, as it can lead to cross-platform compatibility wierdness. It’s not really a problem with web output like this, but it’s a bad habit to get into. You should either use
\r,\nand\r\nas appropriate, or if you must put literals into the source code, use heredoc syntax. Remember that escape sequences like\r\nare only interpolated in double quoted strings!!!