WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : color codes for positive and negative numbers
Categories : PHP, MySQL, Databases, HTML Update Picture
SL Lee
Date : Sep 10th 2003
Grade : 2 of 5 (graded 7 times)
Viewed : 16042
File : 3735.gif
Images : No Images for this code example.
Search : More code by SL Lee
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

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>



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
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
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields
Categories : MySQL, Date Time, PHP, Databases
GroupIT Engine v1.00rc1
Categories : PHP, Content Management, MySQL, Databases
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
Simple function to return the number of days in a time span between 2 given dates.
Categories : PHP, Date Time, MySQL, Databases
How to thread a list of messages in database and show it in a treelike structure
Categories : PHP, MySQL, Databases
[PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more.
Categories : PHP, PHP Classes, Databases, MS SQL Server, MySQL
Newbie Notes #4 - Trapping dumb MySQL query errors
Categories : PHP, Databases, MySQL, Debugging, Beginner Guides
Creating thumbnails from MySQL Blobs online
Categories : PHP, MySQL, Graphics, HTML and PHP, Databases
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases