...

View Full Version : table



bunny1
03-08-2007, 11:11 PM
My code below displays data from the database in a table.
Im finding it hard to change the font of the data in the table.
Where can i do this? When i add a font tag just after the <table> tag and the closing tag before the </table> tag i get errors??

thanks




<?php echo "<table border='1'>
<tr>
<th>Product Code</th>
<th>Name</th>
<th>Product Type</th>
<th>Picture</th>
<th>Description</th>
<th>Stock</th>
<th>Price</th>


</tr>";

while($row = @mysql_fetch_array($result))
{

if ($row['Department'] == $var)
{
echo "<tr>";
//echo "<td>" . $row['Department'] . "</td>";
echo "<td>" . $row['Prod_code'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Prod_Type'] . "</td>";
echo "<td><img height = 50 width = 50 src = " . $row['Picture'] . "></td>";
echo "<td>" . $row['Description'] . "</td>";
echo "<td>" . $row['Stock'] . "</td>";
echo "<td>" . $row['Price'] . "</td>";
echo "</tr>";
}
}
echo "</table>";mysql_close($con);
?>

phoenixshade
03-08-2007, 11:18 PM
Stay far, far away from the <font> tag. Use CSS instead to style your <td>s and <th>s, something like this:

td {
font-family:verdana,arial,sans-serif;
font-size:12px;
color:#330;
}
th {
font-family:georgia,times,serif;
font-size:12px;
font-weight:bold;
color:#000;
background-color:#DEF;
}
The <font> tag is deprecated and it is evil.

bunny1
03-08-2007, 11:20 PM
problem is, this code is within a page and i dont want to change the font for the whole page.just for the table!

thanks

bunny1
03-08-2007, 11:24 PM
ok blonde moment
sorry!
i got it
thanks that's working great!

phoenixshade
03-08-2007, 11:27 PM
problem is, this code is within a page and i dont want to change the font for the whole page.just for the table!
The css I gave won't change it for the whole page, unless the whole page is formatted using <table>s. If that's the case, change this in the first line of your php:

<?php echo "<table border=\"1\" class=\"mytable\">
and change this in the css I've given:

.mytable td {
font-family:verdana,arial,sans-serif;
font-size:12px;
color:#330;
}
.mytable th {
font-family:georgia,times,serif;
font-size:12px;
font-weight:bold;
color:#000;
background-color:#DEF;
}

timgolding
03-08-2007, 11:28 PM
pheonixshade is correct all styling of... well anything should be done with css :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum