1

I want to apply background colour to a table. I have written table using echo command , but am confused about how to apply bgcolor can any one guide me..

print("<table align='center' width='50%' border=1> ");
echo "<TR><TD> Sr.No </td>";
echo "<td  width=\"16%\" bgcolor=\"#CCCCCC\"> delete</td>";
echo "<Td> File Name </td> ";
echo "<td> Share It </td>";
echo "</tr></table>";
luiges90
  • 4,493
  • 2
  • 28
  • 43

3 Answers3

2
echo '<tr><td> Sr.No</td>';
echo '<td width="16%" bgcolor="' . $colorVariable .  '"> delete</td>';
echo '<td> File Name </td>';
echo '<td> Share It</td></tr>';
Vyacheslav Voronchuk
  • 2,403
  • 19
  • 16
2

The "'s are colliding. You need to escape the character, like below.

echo"<td  width=\"16%\" bgcolor=\"#CCCCCC\"> delete</td>";
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
0

try

echo '<td  width="16%" bgcolor="#CCCCCC"> delete</td>';

PHP double quote and single quote

$some="Oh god";

echo "My answer is $some ";

//result is: My answer is Oh god

In the above, using double quotes, the variable $someis evaluated within the quotes and the result isn't what is expected: the variable is evaluated to Oh god. Variables, but not functions or constants, are evaluated even when enclosed in double quotes.

echo 'My answer is $some';

//result is: My answer is $some.

When single quotes are used, as above, the variable isn't evaluated and is printed on the screen literally as $some.


good read

Is there a performance benefit single quote vs double quote in php?

Community
  • 1
  • 1
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143