|
|
|
The following shows a table drawn from a databse (MySql in this case) using php to give red fonts for negative number and blue for positive numbers. The rows are also in alternate colors. You need t ofill in your own data and parameters for the database, of course.
<table border=0 bgcolor=white width="502" cellpadding="0"
cellspacing="0">
<tr><td>
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="336699">
<td align=middle id="header">a</td>
<td align=middle id="header">b</td>
<td align=middle id="header">c</td>
<td align=middle id="header">d</td>
<td align=middle id="header">e</td>
</tr>
<?php
mysql_connect(localhost,user,password);
$database="your_database";
@mysql_select_db("$database") or die( "Unable to select database");
$table="your_table";
$query="select * from $table
where $table.data1=something AND $table.data2 >0 order by this_order";
$result=mysql_query($query);
mysql_close();
/*Display Results*/
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
$a=mysql_result($result,$i,"a");
$b=mysql_result($result,$i,"b");
$c=mysql_result($result,$i,"c");
$d=mysql_result($result,$i,"d");
$e=mysql_result($result,$i,"e");
//Alternate row colors in our table
print ($i % 2) ? "<tr bgcolor=\"CCCCCC\">" : "<tr
bgcolor=\"BEEFFF\">";
print "<td align=right>$a</td>";
print "<td align=right>$b</td>";
print "<td align=right>$c</td>";
print "<td align=right>$d</td>";
print "<td align=right><span style=\"color:";
if ($d > 0){
print "blue";
} else {
print "red";
}
print ";\">$e</span></td>";
++$i;
}
?>
</table>
|
|
| bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Newbie Notes #10 - Generating drop downs Categories : PHP, MySQL, HTML, Beginner Guides, Databases | | | Paginator - a class that can help you to split MySQL database query result sets to pages. Categories : MySQL, Databases, HTML, PHP | | | PHP-CSL PHP Code Snippet Library, A very handy application designed to save you many hours by storing all your code snippets, classes and functions. Categories : PHP, Utilities, MySQL, Databases, To PHP | | | phpMyAdmin is intended to handle the adminstration of MySQL
over the web. Categories : Databases, MySQL, Complete Programs, PHP | | | Simple database class Categories : PHP, PHP Classes, MySQL, Databases | | | Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | Database resultset navigation Categories : PHP, HTML and PHP, Databases, MySQL, Navigation | | | This program will take data from a user via a web based form, validate it, show it
to the user for re-validation, and finally insert it into the database. Plenty of
sanity checking on the fields in the form.
Categories : MySQL, HTML and PHP, PHP, Complete Programs, Databases | | | formating MySQL Timestamp to get a propper Output.
related : Timestamp, ereg_replace, mysql, substr Categories : MySQL, PHP, Date Time, Databases | | | The first step Guest Book ... ^^ Categories : MySQL, PHP, Apache, HTML, HTTP | | | PHP Transfer data from text file to Mysql Table Categories : PHP, PHP Classes, Filesystem, Databases, MySQL | | | Shopping Cart e-Commerce Solution Categories : Complete Programs, PHP, MySQL, Databases | | | A login page that require username, password and userlevel. Categories : PHP, Security, Sessions, MySQL, Databases | |
|
|