Page 1 of 1

How do I apply CSS Style to PHP code output

Posted: Tue Aug 23, 2005 10:15 am
by mhouldridge
Hi,

I have some code which outputs data from a database into a table and I would like to know how I can apply a style to this output, from my stylesheet. Here is the code;

Code: Select all

mysql_select_db("audit") or die("Problem selecting database");
$query = "SELECT * FROM dedicated order by asset";
$result = mysql_query($query) or die ("Query failed");
$numofrows = mysql_num_rows($result);
echo "<TABLE BORDER=\"0\" table width=\"100%\">\n";
echo "<TR bgcolor=\"#cccccc\"><TD font colour=\"red\"><b>Asset</b></TD><TD><b>Title</b></TD><TD><b>Customer</b></TD><TD><b>Type</b></TD><TD><b>IP address</b></TD><TD><b>Reconciled</b></TD><TD><b>Edit</b></TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
    $row = mysql_fetch_array($result); //get a row from our result set
	if($i % 2) {
		echo "<TR bgcolor=\"#f5f7fb\">\n";    
		} 
	else {     
		echo "<TR bgcolor=\"#e6e6fb\">\n";    
		}
 	echo "<TD><font color=\"red\"><b><a href='viewall.php?varl=".$row['asset']."'>".$row['asset']."</a></b></font></TD><TD><font size=\"2\">".$row['title']."</TD><TD><font size=\"2\">".$row['customer']."</TD><TD><font size=\"2\">".$row['type']."</TD><TD><font size=\"2\">".$row['IP']."</TD><TD><font size=\"2\">".$row['recon']."</TD><TD><font color=\"red\"><a href='sysdocupdate.php?varl=".$row['asset']."'>Edit</a></font></TD>\n"; 
    echo "</TR>\n";
		}
	echo "</TABLE>\n";

Posted: Tue Aug 23, 2005 10:44 am
by patrikG
and woopeeeh! moved to client-side.

Posted: Tue Aug 23, 2005 12:45 pm
by feyd
you'll set the style like any other output, set id's and classes in the html code, then use those to create the stylesheet data. A class for the table, possibly table row, and the header row are the basics..