LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2010, 12:58 PM   #1
lrios
Member
 
Registered: Mar 2008
Location: Arg
Distribution: Cent0S
Posts: 48

Rep: Reputation: 15
Red face About color font in script PHP


I don't know how to compare values 0n $rVal['FechaTrx'] and $rVal['TipoMSj'].

2 points:
1) I want to see three colors in the html table (output). For the example
(like a semaphore):
$fecha5Dias = date () --> green color: Recently transactions (today)
$fecha = (date ())-5 --> yellow color: mean 5 days with no transactions
$fecha = (date ())-10 --> red color: mean 10 days with no transactions

2) I want two colors too in the html table. Red 0r Green. For the example if $rVal['TipoMsj'] = OK --> show green color font.
If $rVal['TipoMsj'] = TO (time out) --> show red color font.





PHP Code:
<?php

 
include ("database.class.php");
 
$obrasSocialesActivas file ('obrasSocialesActivas.txt');
 
$db = new database ("mssql","192.168.x.x","name_BD","user","pass");
 
$lineas count($obrasSocialesActivas);        
 
$fecha date("Y-m-d");
 
$fecha5Dias date("Y-m-d"strtotime("-5 day"strtotime($fecha)));
 
         
$mensaje .= "<center>";
         
$mensaje .= strftime("Day Transaction %d / %m / %Y" ,time());
         
$mensaje .= "</center>";
 
 for (
$i=0$i $lineas$i++) {
         
$obraSocial explode("|"$obrasSocialesActivas[$i]);
         
$cuitOS trim ($obraSocial[0]);
         
$nombreOS $obraSocial[1];
         
$siglaOS trim($obraSocial[2]);
         
$codigoEM trim($obraSocial[3]);

 
//Tx:Transaction

/* Query SQL */
         
$db->query (sprintf ("select top 15 IdMsj, TipoMsj, FechaTrx, HoraTrx, RazonSocial, MensajePrinter from xchangeml..ticket (nolock)
        where CuitFinanciador = '%s' and FechaTrx >= '%s'  order by IdMsj desc"
$cuitOS$fecha5Dias));

        
$rVal $db->get_row();                         
        
$Id $rVal['IdMsj'];
        
$Response $rVal['TipoMsj'];          
        
$DateTx $rVal['FechaTrx'];          
        
$HourTx $rVal['HoraTrx'];
    

 
        
$mensaje .= "<div style=\"border: 1px solid blue;\">";
        
$mensaje .= "<strong><big>".$nombreOS." - <u>".$siglaOS." </u>(".$codigoEM.") </big></strong><br>";
        
$mensaje .= "<table CellPadding=\"8\">";
        
$mensaje .= "<tr>";
        
$mensaje .= "<td><strong>Id_Mensaje</strong></td>";
        
$mensaje .= "<td><strong>Type_0f_Messaje</strong></td>";
        
$mensaje .= "<td><strong><center>DaTe</strong></center></td>";
        
$mensaje .= "<td><strong><center>Hour</strong></center></td>";
        
$mensaje .= "<td><strong><center>name</center></strong></td>";
        
$mensaje .= "<td><strong><center>Description</center></strong></td>";
        
$mensaje .= "</tr>";

    
/* if ($DateTx-5)  transaction
{
 --then color font yellow

else
 {

 ($DateTx-10) -- transaction
 --then color font red

*/
       
while($fila $db->get_row()){
 
                         
$mensaje .= "<tr>";
                         
$mensaje .= "<td>" .$Id ."</td>";
                         
$mensaje .= "<td>".$Response ."</td>";
                         
$mensaje .= "<td>".$DateTx ."</td>";
                         
$mensaje .= "<td>".$HourTx ."</td>";
                        
$mensaje .= "<td>".$fila['Name']."</td>";
                        
$mensaje .= "<td>".$fila['MessajePrinter']."</td>";
                          
$mensaje .= "</tr>";
  
 
                }

     
$mensaje .= "</table>";
         
$mensaje .= "</div>";
         
$mensaje .= "<br>";
 
 }

$db->disconnect();
unset (
$db);
 
Old 01-28-2010, 02:39 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
You would just add the appropriate tags to the HTML after performing a check on the data (font or td) to determine the particular color of that information.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change font color and font size in terminal ? wlaw Linux - Newbie 3 05-15-2007 08:57 PM
QT and font color atomas123 Programming 2 12-20-2005 01:20 PM
removing php font tags for cut and paste of script? rioguia Linux - Newbie 0 10-16-2004 07:23 AM
font color Joey.Dale Linux - General 1 06-19-2003 12:52 PM
change font color...no NOT in X centr0 Slackware 4 05-01-2003 03:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration