Link to home
Start Free TrialLog in
Avatar of duta
duta

asked on

How to embed CSS in PHP?

Hi experts:

I have a HTML  CSS code code (as seen below) embedded in PHP.

But it is not working.  
Can you kindly give me a tip?

Thanks!

<? php
 
'<style type="text/css">
table.myTable td
{
  border: solid 1px black;
}
table.myTable th
{
  border: solid 1px black;
  background-color:silver;
}
</style>'
 
echo '<table class = "myTable"><tr><th> Name</th><th> Email</th></tr>';
 
    while (!$result->EOF)
    {
 
      echo '<tr>' .
      
          '<td>' . $result -> fields ['Name']. '</td>' .
          '<td>' . $result -> fields ['Email'] . '</td>' .
          '</tr>';

Open in new window

SOLUTION
Avatar of JoachimMartinsen
JoachimMartinsen
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Loganathan Natarajan
try this,


<? php
 
echo '<style type="text/css">
table.myTable td
{
  border: solid 1px black;
}
table.myTable th
{
  border: solid 1px black;
  background-color:silver;
}
</style>';
 
echo '<table class = "myTable"><tr><th> Name</th><th> Email</th></tr>';
 
    while (!$result->EOF)
    {
 
      echo '<tr>' .
      
          '<td>' . $result -> fields ['Name']. '</td>' .
          '<td>' . $result -> fields ['Email'] . '</td>' .
          '</tr>';
		  
		  ?>

Open in new window

Avatar of duta
duta

ASKER

Thank you so much for your kind, prompt tip.

By the way, I  inserted "Echo" command. Still I got an error message from

the bottom line of the code (in Code Snippet box):


//  Errors comes from the line below

echo "<table class = 'myTable'><tr><th> Name</th><th> Email</th></tr>";
<?php
 
function printEntries($result)
{
 echo
"<style type='text/css'>
table.myTable td
{
  border: solid 1px black;
}
table.myTable th
{
  border: solid 1px black;
  background-color:silver;
}
</style>"
 
 
 
 
echo "<table class = 'myTable'><tr><th> Name</th><th> Email</th></tr>";

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you have missed, ;

</style>"; 

Open in new window

Avatar of duta

ASKER

Thank you very much!