...

View Full Version : Change html table font style in php



daza93
11-19-2011, 09:22 AM
I'm using the following code to display data from my database but how do i change the font size, type of the table cells?



//Retrive all the data from the table
$result = mysql_query("SELECT * FROM stats2") or die(mysql_error());

echo "<table border='1' cellspacing='0' width='593'>";
echo "<tr> <th bgcolor='#BFBFBF' align='center'>Name</th> <th bgcolor='#BFBFBF' align='center'>Apps(Sub)</th> <th bgcolor='#BFBFBF' align='center'>Goals/CS</th> <th bgcolor='#BFBFBF' align='center'>Yellows</th> <th bgcolor='#BFBFBF' align='center'>Reds</th> <th bgcolor='#BFBFBF' align='center'>MOTM</th> </tr>";


// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {

// Print out the contents of each row into a table
echo "<tr><td align='center'>";
echo $row['name'];
echo "</td><td align='center'>";
echo $row['apps']; echo '('; echo $row['sub']; echo ')';
echo "</td><td align='center'>";
echo $row['goals'];
echo "</td><td align='center'>";
echo $row['yellows']";
echo "</td><td align='center'>";
echo $row['reds'];
echo "</td><td align='center'>";
echo $row['MOTM'];
echo "</td></tr>";
}

echo "</table>";

Adee
11-19-2011, 09:54 AM
with css.....

<style type="text/css">
td { your styles here.. }
tr { your styles here.. }
</style>

??

daza93
11-19-2011, 10:16 AM
with css.....

<style type="text/css">
td { your styles here.. }
tr { your styles here.. }
</style>

??

Where would I place this code?

Tried a couple of times put doesn't seem to work

Adee
11-19-2011, 10:31 AM
Where would I place this code?

Tried a couple of times put doesn't seem to work



echo <<<CSS
<style type="text/css">
td { font-family: courier; color: red; }
</style>
CSS;

myfayt
11-19-2011, 01:25 PM
Make a new file, put in the CSS coding such as Adee has shown below, and save with with a name like style.css


<style type="text/css">
td { font-family: courier; color: red; }
</style>

Then in the file where you want to use it, in the header put this.


<link rel="stylesheet" type="text/css" href="mystyle.css" />

change mystyle.css to the path and name of your file.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum