Jump to content

Dynamic HTML Table Problems


Dan_Mason

Recommended Posts

Hello! First post so sorry if you've heard this all before etc but i really could use the help!

 

As You can See below, the syntax is correct, and i have no problems in generating a Dynamic HTML table, using MySQL.

Right.jpg

 

But Here, when I try to change the cell width, the text editor shows that my Syntax is wrong, and i dont really understand what im doing wrong.

wrong.jpg

 

And when i bring it up in the browser, the following error occurs:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\AppServ\www\Practice\DynamicReport.php on line 99

 

Can Anyone Help Me?   ???

Link to comment
https://forums.phpfreaks.com/topic/129544-dynamic-html-table-problems/
Share on other sites

It's width="value". But that's not the point. Notice how you open the string with double quotes. You cannot place double quotes inside the string UNLESS you escape them. Here is an example:

 

echo "<td width="5">Hello</td>"; #Wrong, this will throw a parse error because you are using double quotes inside the string.

echo "<td width=\"5\">Hello</td>"; #Correct, see how the double quotes are escape beforehand.

echo '<td width="5">Hello</td>'; #Correct, notice how I opened the string with single quotes instead. That way I can use double quotes without the need to escape them.

 

Hope that makes some sense. Oh and one more thing:

 

echo '<td width="5">$variable</td>'; #This will not echo the contents of $variable, instead it will echo the text $variable. This is because any variables wrapped inside single quotes are not parsed.
echo '<td width="5">' . $variable . '</td>'; #This will work. 

 

Good luck!

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.