/    Sign up×
Community /Pin to ProfileBookmark

need help in putting style in if condition

Hi…

I need a condition in my webpage that if the LOGIN fields is [B]NULL[/B].
That row will be highlighted in RED.

i try this code but it did not work…

[code]
$LOGIN = $DTR->fields[‘LOGIN’];
if($LOGIN == NULL){
“<td style=’background-color:RED’>”;
//echo ‘<style = background-color: RED;>’.$DTR.'</style>’;
}
[/code]

I have this code:

[code]
<?php

include ‘config.php’;

$currentEmpID = $_SESSION[’empID’];

if(!isset($_POST[‘Regsubmit_’])){

$DATE1 = $_GET[‘Regfirstinput’];
$DATE2 = $_GET[‘Regsecondinput’];

$sql = “SELECT a.EMP_NO, CONCAT(LNAME, ‘, ‘ , FNAME, ‘ ‘, MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN ‘$DATE1’ AND ‘$DATE2’
AND em.STATUS IN (‘Reg Operatives’, ‘Reg Staff ‘) OR LOGIN IS NULL”;

$DTR = $conn3->GetAll($sql);

$LOGIN = $DTR->fields[‘LOGIN’];

if($LOGIN == NULL){
“<td style=’background-color:RED’>”;
//echo ‘<style = background-color: RED;>’.$DTR.'</style>’;
}
$smarty->assign(‘attendance’, $DTR);

}
$smarty->display(‘header_att.tpl’);
$smarty->display(‘RegAttendance.tpl’);
$smarty->display(‘footer.tpl’);

?>
[/code]

[code]
<div id=”attendance” style=”width: 580px; height: 420px; overflow: auto; padding: 5px; top:95px”>
<fieldset>
<legend>Employee Attendance</legend>
<table border=”1″>
<tr>
<td colspan=”2″ style=”text-align:center”>Employee No</td>
<td colspan=”2″ style=”text-align:center”>Employee Name</td>
<td colspan=”2″ style=”text-align:center”>Time In</td>
<td colspan=”2″ style=”text-align:center”>Time Out</td>
</tr>

{section name=att loop=$attendance}
<tr>
<td colspan=”2″>{$attendance[att].EMP_NO}</td>
<td colspan=”2″>{$attendance[att].FULLNAME}</td>
<td colspan=”2″>{$attendance[att].LOGIN|date_format:”%d-%m-%Y %I:%M %p”}</td>
<td colspan=”2″>{$attendance[att].LOGOUT|date_format:”%d-%m-%Y %I:%M %p”}</td>
</tr>
{sectionelse}
<tr><td colspan=”1″>No DATA</td></tr>
{/section}
</table>
</fieldset>
</div>
[/code]

Thank you

to post a comment
PHP

29 Comments(s)

Copy linkTweet thisAlerts:
@007JulienDec 23.2011 — The table or td attribute was bgcolor="#FF0000". But this attribute is depreciated. Then a class="rdc" with a style would be probably better.
[CODE]<style type="text/css">
.rdc {background-color:#ff0000;}
</style> [/CODE]
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 23.2011 — I used this code:

<i>
</i>

$LOGIN = $DTR-&gt;fields['LOGIN'];
if($LOGIN == NULL){
echo "&lt;td style='background-color:RED'&gt;$DTR&lt;/td&gt;";
}
else
{
echo "&lt;td&gt;$DTR&lt;/td&gt;";
}

but it wont work..

How can i add the css you suggested in my code?


Thank you
Copy linkTweet thisAlerts:
@bionoidDec 23.2011 — What was the value of $LOGIN, cause the style looks alright ?

If the <td> goes green then $LOGIN does not equal NULL.

[code=php]$LOGIN = $DTR->fields['LOGIN'];
if($LOGIN == NULL){
echo "<td style='background-color:red;'>$DTR</td>";
}
else
{
echo "<td style='background-color:green;'>$DTR</td>";
}[/code]


Although, it looks like your using an object to populate a <td> ?

If you want to use 007Julien's example in your code, stick the class he gave you in the <head> or stylesheet, then write the code like:

[code=php]$LOGIN = $DTR->fields['LOGIN'];
if($LOGIN == NULL){
echo "<td class='rdc'>$DTR</td>";
}
else
{
echo "<td>$DTR</td>";
}[/code]
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 23.2011 — $LOGIN has a DATETIME value like for example 2011-12-01 02:00:00, but i have also data NULL .


when i tried your suggestion and the using class...

I got only Array word..

Thank you
Copy linkTweet thisAlerts:
@bionoidDec 23.2011 — I don't see how that <td> is being used in your <table>. If it is not inside a <table> and <tr> element it will not show the background color.

Out of curiosity, please try this...

[code=php]if (!$DTR->fields['LOGIN']){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}[/code]
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 23.2011 — <i>
</i>&lt;div id="attendance" style="width: 580px; height: 420px; overflow: auto; padding: 5px; top:95px"&gt;
&lt;fieldset&gt;
&lt;legend&gt;Employee Attendance&lt;/legend&gt;
&lt;table border="1"&gt;
&lt;tr&gt;
&lt;td colspan="2" style="text-align:center"&gt;Employee No&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Employee Name&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Time In&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Time Out&lt;/td&gt;
&lt;/tr&gt;

{section name=att loop=$attendance}
&lt;tr&gt;
&lt;td colspan="2"&gt;{$attendance[att].EMP_NO}&lt;/td&gt;
&lt;td colspan="2"&gt;{$attendance[att].FULLNAME}&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;{$attendance[att].TimeIn}&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;{$attendance[att].LOGIN|date_format:"&amp;#37;d-%m-%Y %I:%M %p"}&lt;/td&gt;
&lt;td colspan="2"&gt;{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;{$attendance[att].TimeOut|date_format:"%d-%m-%Y %I:%M %p"}&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;{$attendance[att].TimeOut}&lt;/td&gt; --&gt;
&lt;/tr&gt;
{sectionelse}
&lt;tr&gt;&lt;td colspan="1"&gt;No DATA&lt;/td&gt;&lt;/tr&gt;
{/section}
&lt;/table&gt;
&lt;/fieldset&gt;
&lt;/div&gt;


when I try this code:

<i>
</i> if (!$DTR-&gt;fields['LOGIN']){
echo '&lt;div style="background-color: red;"&gt;' . $DTR . '&lt;/div&gt;';
} else {
echo '&lt;div style="background-color: green;"&gt;' . $DTR . '&lt;/div&gt;';
}


at the top of my webpage displayed Array and it has a color red..

but my table row that has null value has still no color..

Thank you
Copy linkTweet thisAlerts:
@bionoidDec 23.2011 — Yes, I thought it would.

Try this then:

[code=php]if (!$DTR->fields['LOGIN']){
$DTR->fields['LOGIN'] = '<div style="background-color: red;">No Login Date</div>';
}[/code]


I am assuming an assignment to this object is possible ?
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 23.2011 — No output...No color at all...

this code :

<i>
</i>if (!$DTR-&gt;fields['LOGIN']){
echo '&lt;div style="background-color: red;"&gt;' . $DTR . '&lt;/div&gt;';
} else {
echo '&lt;div style="background-color: green;"&gt;' . $DTR . '&lt;/div&gt;';
}


is ok but the color should be in the row with NULL value..


thank you
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 23.2011 — When i try this code:

<i>
</i> if ($DTR-&gt;fields['LOGIN'] == 'NULL'){
echo '&lt;div style="background-color: red;"&gt;' . $DTR . '&lt;/div&gt;';
} else {
echo '&lt;div style="background-color: green;"&gt;' . $DTR . '&lt;/div&gt;';
}


the output is Array then has a background color green..

I want the color green is in the row that has a null value..

Thank you
Copy linkTweet thisAlerts:
@bionoidDec 23.2011 — NULL and 'NULL' are different things.

[code=php]if ($DTR->fields['LOGIN'] == NULL){
echo '<div style="background-color: red;">' . $DTR . '</div>';
} else {
echo '<div style="background-color: green;">' . $DTR . '</div>';
}[/code]


I believe you're not getting any output when assigning the background color back to LOGIN is because it's trying to convert it to a date, and obviously has a problem with it.

My suggestion is to do something like this:

[CODE]<div id="attendance" style="width: 580px; height: 420px; overflow: auto; padding: 5px; top:95px">
<fieldset>
<legend>Employee Attendance</legend>
<table border="1">
<tr>
<td colspan="2" style="text-align:center">Employee No</td>
<td colspan="2" style="text-align:center">Employee Name</td>
<td colspan="2" style="text-align:center">Time In</td>
<td colspan="2" style="text-align:center">Time Out</td>
</tr>

{section name=att loop=$attendance}
<tr>
<td colspan="2">{$attendance[att].EMP_NO}</td>
<td colspan="2">{$attendance[att].FULLNAME}</td>

<!--<td colspan="2">{$attendance[att].TimeIn}</td> -->
<td colspan="2"[COLOR="Red"] class="{$attendance[att].LOGIN_CLASS}"[/COLOR]>{$attendance[att].LOGIN|date_format:"&#37;d-%m-%Y %I:%M %p"}</td>
<td colspan="2">{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}</td>
<!--<td colspan="2">{$attendance[att].TimeOut|date_format:"%d-%m-%Y %I:%M %p"}</td>-->
<!-- <td colspan="2">{$attendance[att].TimeOut}</td> -->
</tr>
{sectionelse}
<tr><td colspan="1">No DATA</td></tr>
{/section}
</table>
</fieldset>
</div>[/CODE]


... and change your sql statement to ...

[CODE]$sql = "SELECT [COLOR="red"]IF(ISNULL(a.LOGIN), 'rdc', '') AS LOGIN_CLASS, [/COLOR]a.EMP_NO, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'
AND em.STATUS IN ('Reg Operatives', 'Reg Staff ') OR LOGIN IS NULL";[/CODE]


... then add the following css 007Julien suggested into your <head> ...

[CODE]<style type="text/css">
.rdc {background-color: #f00;}
</style>[/CODE]


If this works you will not need the PHP LOGIN check.

This is completely untested.
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 23.2011 — I tried your suggestion and yet it did not work?

Thank you
Copy linkTweet thisAlerts:
@bionoidDec 23.2011 — May I see the output your code produced?
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — i attach the image of code produce.


Thank you
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — Sorry, I need to see the code. I want to know if what I have suggested has been placed properly.
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — <i>
</i>&lt;?php

include 'config.php';

$currentEmpID = $_SESSION['empID'];

if(!isset($_POST['Regsubmit_'])){

<i> </i>$DATE1 = $_GET['Regfirstinput'];
<i> </i>$DATE2 = $_GET['Regsecondinput'];

$sql = "SELECT IF(ISNULL(a.LOGIN), 'rdc', '') AS LOGIN_CLASS, a.EMP_NO, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'
AND em.STATUS IN ('Reg Operatives', 'Reg Staff ') OR LOGIN IS NULL";

<i> </i>$DTR = $conn3-&gt;GetAll($sql);

<i> </i>$smarty-&gt;assign('attendance', $DTR);

}
$smarty-&gt;display('header_att.tpl');
$smarty-&gt;display('RegAttendance.tpl');
$smarty-&gt;display('footer.tpl');

?&gt;


RegAttendance.tpl

<i>
</i>&lt;style type="text/css"&gt;
.rdc {background-color:#ff0000;}
&lt;/style&gt;
&lt;div class="NavAtt"&gt;
&lt;p&gt;
&lt;input type="button" name="UPLOAD" value="UPLOAD ATTENDANCE" onclick="uploadregularattendance()"&gt;
&lt;input type="button" name="REGULAR" value="DISPLAY ATTENDANCE" onclick="regularattendance()"&gt;
&lt;input type="button" name="approve" value="APPROVE" onclick="ApproveAttendance()"&gt; <br/>
&lt;/p&gt;
&lt;/div&gt;
&lt;div id="calendar"&gt;
&lt;fieldset&gt;
&lt;legend&gt;Calendar&lt;/legend&gt;
&lt;input type="text" name="Regfirstinput" id="Regfirstinput" size="10" &gt; &lt;small&gt;&lt;a href="Javascript:showCal('RegCalendar1')"&gt;Select Date&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;&lt;input type="text" name="Regsecondinput" id="Regsecondinput" size="10" &gt; &lt;small&gt;&lt;a href="Javascript:showCal('RegCalendar2')"&gt;Select Date&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;&lt;input type="button" name="Regsubmit_" value="Submit" onclick="regulardisplayattendance()"/&gt;&lt;/p&gt;
&lt;/fieldset&gt;
&lt;/div&gt;

&lt;div id="attendance" style="width: auto; height: 420px; overflow: auto; padding: 5px; top:95px;"&gt;
&lt;fieldset&gt;
&lt;legend&gt;Employee Attendance&lt;/legend&gt;
&lt;table border="1" style="font-family:"Times New Roman",Times,serif; font-size:10px"&gt;
&lt;tr&gt;
&lt;td colspan="2" style="text-align:center"&gt;Employee No&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Employee Name&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Time In&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Time Out&lt;/td&gt;
&lt;/tr&gt;

{section name=att loop=$attendance}
&lt;tr&gt;
&lt;td colspan="2"&gt;{$attendance[att].EMP_NO}&lt;/td&gt;
&lt;td colspan="2"&gt;{$attendance[att].FULLNAME}&lt;/td&gt; <br/>
&lt;td colspan="2" class="{$attendance[att].LOGIN_CLASS}"&gt;{$attendance[att].LOGIN|date_format:"%d-%m-%Y %I:%M %p"}&lt;/td&gt;
&lt;td colspan="2"&gt;{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}&lt;/td&gt;
&lt;/tr&gt;
{sectionelse}
&lt;tr&gt;&lt;td colspan="1"&gt;No DATA&lt;/td&gt;&lt;/tr&gt;
{/section}
&lt;/table&gt;
&lt;/fieldset&gt;
&lt;/div&gt;
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — ?

Ok, good. I see the code is there. Could I also see the html output of the code please?

Also, please move the <style> into your documents <head>, or move the [B]rdc[/B] style into a stylesheet your using. It won't work where it is now.
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — What do you mean html output??

is it the actual image of webpage?
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — i do your suggestion that I will put the css code in my css file..

Still wont work


Thank you
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — I want to see the source code of how the that image is in the browser in html.

You can get it by right-clicking the page in the browser and choosing "View Source" in IE, or "View Page Source" in FF.
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — here is the source code:

<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;!--&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; --&gt;
&lt;!--&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; --&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Pragma" content="no-cache"&gt;
&lt;!--&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;--&gt;
&lt;title&gt;DSPI Payroll System&lt;/title&gt;

&lt;link rel="stylesheet" type="text/css" href="paycss.css" /&gt;



&lt;script type="text/javascript" src="reg_cal2.js"&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="reg_cal_conf2.js"&gt;&lt;/script&gt;


&lt;script type="text/javascript"&gt;

function attendanceemp(){
document.sampleform.action="displayDate.php";
document.sampleform.submit();
}

function attendance(){
document.sampleform.action="Attendance.php";
document.sampleform.submit();
}

function casualattendance(){
document.sampleform.action="displayDate.php";
document.sampleform.submit();
}
function regularattendance(){
document.sampleform.action="RegAttendance.php";
document.sampleform.submit();
}
function uploadregularattendance(){
document.sampleform.action="upload_reg_att.php";
document.sampleform.submit();
}

function uploadcasualattendance(){
document.sampleform.action="upload_att.php";
document.sampleform.submit();
}


function regulardisplayattendance(){
var Regfirstinput = document.getElementById('Regfirstinput').value;
var Regsecondinput = document.getElementById('Regsecondinput').value

<i> </i>document.sampleform.action="DisplayRegAttendance.php?Regfirstinput="+Regfirstinput+"&amp;Regsecondinput="+Regsecondinput;
<i> </i>document.sampleform.submit();
}

function importregularattendance(){
document.sampleform.action="import_reg_att.php";
document.sampleform.submit();
}
function importcasualattendance(){
document.sampleform.action="import_att.php";
document.sampleform.submit();
}
function payOut(){
document.sampleform.action="payroll_category.php";
document.sampleform.submit();
}
function AttendancePayroll(){
document.sampleform.action="Attendance.php";
document.sampleform.submit();
}

function ApproveAttendance(){
var Regfirstinput = document.getElementById('Regfirstinput').value;
var Regsecondinput = document.getElementById('Regsecondinput').value

<i> </i>document.sampleform.action="ApproveAttendance.php?Regfirstinput="+Regfirstinput+"&amp;Regsecondinput="+Regsecondinput;
<i> </i>document.sampleform.submit();
}
&lt;/script&gt;

&lt;body onload="document.forms[0].reset()"&gt;
&lt;form name="sampleform" method="post" enctype="multipart/form-data"&gt;
&lt;h2 class="sysname"&gt; Payroll System &lt;/h2&gt;

&lt;!--&lt;input type="button" name="logout" value="Log Out" onclick="payOut()"&gt;--&gt;
&lt;!--&lt;input type="button" name="loan" value= "Loan Form" class="loan" onclick=""&gt;
&lt;img src="logout70x70.png" onclick="payOut()" class="a"&gt;--&gt;
&lt;div class="btn_header_attendance_1"&gt;
&lt;!--&lt;input type="button" name="General" value="General" onclick="displaygeneral()"&gt;
&lt;!--&lt;input type="button" name="Attendance" value="Attendance" onclick="attendance()"&gt;
&lt;input type="button" name="OT" value= "OT Form" onclick="OtFrm()"&gt;
&lt;input type="button" name="loan" value= "Loan Form" onclick="loanFrm()"&gt;
&lt;input type="button" name="otherded" value= "Deductions" onclick="Deductions()"&gt; --&gt;
&lt;input type="button" name="Back" value="Back" onclick="AttendancePayroll()"&gt; <br/>
&lt;input type="button" name="logout" value="Main" onclick="payOut()"&gt;
&lt;/div&gt;
&lt;!--&lt;div id="header_line"&gt;
&lt;hr style="border: 1px solid #000; border-color:#666666;" /&gt;
&lt;/div&gt; --&gt;




&lt;!--&lt;div class="a" onclick="payOut()"&gt;Log Out&lt;/div&gt;--&gt;

&lt;!--End of Header--&gt;&lt;div class="NavAtt"&gt;
&lt;p&gt;
&lt;input type="button" name="UPLOAD" value="UPLOAD ATTENDANCE" onclick="uploadregularattendance()"&gt;
&lt;input type="button" name="REGULAR" value="DISPLAY ATTENDANCE" onclick="regularattendance()"&gt;
&lt;input type="button" name="approve" value="APPROVE" onclick="ApproveAttendance()"&gt; <br/>
&lt;/p&gt;
&lt;/div&gt;
&lt;!--&lt;div class="NavAtt"&gt;
&lt;p&gt;
&lt;input type="button" name="CASUAL" value="CASUAL ATTENDANCE" onclick="casualattendance()"&gt;
&lt;input type="button" name="OP_STAFF" value="REGULAR ATTENDANCE" onclick="regularattendance()"&gt; <br/>
&lt;input type="button" name="UPLOAD_REG" value="UPLOAD REGULAR ATTENDANCE" onclick="uploadregularattendance()"&gt;
&lt;/p&gt;
&lt;/div&gt;--&gt;

&lt;div id="calendar"&gt;
&lt;fieldset&gt;
&lt;legend&gt;Calendar&lt;/legend&gt;
&lt;input type="text" name="Regfirstinput" id="Regfirstinput" size="10" &gt; &lt;small&gt;&lt;a href="Javascript:showCal('RegCalendar1')"&gt;Select Date&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;&lt;input type="text" name="Regsecondinput" id="Regsecondinput" size="10" &gt; &lt;small&gt;&lt;a href="Javascript:showCal('RegCalendar2')"&gt;Select Date&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;&lt;input type="button" name="Regsubmit_" value="Submit" onclick="regulardisplayattendance()"/&gt;&lt;/p&gt;
&lt;/fieldset&gt;
&lt;/div&gt;

&lt;!--&lt;div id="calendar_nrs"&gt;
&lt;fieldset&gt;
&lt;legend&gt;NRS&lt;/legend&gt;
&lt;input type="text" name="firstinput" size="10" &gt; &lt;small&gt;&lt;a href="Javascript:showCal('Calendar1')"&gt;Select Date&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;&lt;input type="text" name="secondinput" size="10" &gt; &lt;small&gt;&lt;a href="Javascript:showCal('Calendar2')"&gt;Select Date&lt;/a&gt;&lt;/small&gt;
&lt;p&gt;&lt;input type="button" name="submit_" value="Submit" onclick="attendanceemp();"/&gt;&lt;/p&gt;
&lt;/fieldset&gt;
&lt;/div&gt; --&gt;

&lt;div id="attendance" style="width: auto; height: 420px; overflow: auto; padding: 5px; top:95px;"&gt;
&lt;fieldset&gt;
&lt;legend&gt;Employee Attendance&lt;/legend&gt;
&lt;table border="1" style="font-family:"Times New Roman",Times,serif; font-size:10px"&gt;
&lt;tr&gt;
&lt;td colspan="2" style="text-align:center"&gt;Employee No&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Employee Name&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Time In&lt;/td&gt;
&lt;td colspan="2" style="text-align:center"&gt;Time Out&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;00300395&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 3&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;16-12-2011 08:30 AM&lt;/td&gt;
&lt;td colspan="2"&gt;16-12-2011 05:15 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09300127&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 4&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;17-12-2011 07:36 AM&lt;/td&gt;
&lt;td colspan="2"&gt;17-12-2011 06:00 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09300127&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 4&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;18-12-2011 08:25 AM&lt;/td&gt;
&lt;td colspan="2"&gt;18-12-2011 05:35 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09300127&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 4&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;19-12-2011 07:49 AM&lt;/td&gt;
&lt;td colspan="2"&gt;19-12-2011 04:00 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09300127&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 4&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;20-12-2011 08:40 AM&lt;/td&gt;
&lt;td colspan="2"&gt;20-12-2011 04:35 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09900215&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 5&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;21-12-2011 06:30 AM&lt;/td&gt;
&lt;td colspan="2"&gt;21-12-2011 04:40 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09900215&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 5&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;22-12-2011 07:25 AM&lt;/td&gt;
&lt;td colspan="2"&gt;22-12-2011 04:26 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09900215&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 5&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;23-12-2011 06:42 AM&lt;/td&gt;
&lt;td colspan="2"&gt;23-12-2011 03:45 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;09900215&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 5&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;24-12-2011 07:36 AM&lt;/td&gt;
&lt;td colspan="2"&gt;24-12-2011 03:00 PM&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="2"&gt;00000221&lt;/td&gt;
&lt;td colspan="2"&gt;Employee Name 6&lt;/td&gt; <br/>
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;td colspan="2"&gt;&lt;/td&gt;
&lt;td colspan="2"&gt;&lt;/td&gt;
&lt;!--&lt;td colspan="2"&gt;&lt;/td&gt;--&gt;
&lt;!-- &lt;td colspan="2"&gt;&lt;/td&gt; --&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/fieldset&gt;
&lt;/div&gt;



&lt;div id="footer" &gt;
&lt;hr style="border: 1px solid #000; border-color:#666666;" /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/form&gt;
&lt;/head&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — Thank you.

Ok, looking at the code I do not see the [B]class=""[/B] section in your <td>. That should at least be in there regardless of if the LOGIN value is null or not?

[code=html] <tr>
<td colspan="2">09900215</td>
<td colspan="2">Employee Name 5</td>
<!--<td colspan="2"></td> -->
<td colspan="2">24-12-2011 07:36 AM</td>
<td colspan="2">24-12-2011 03:00 PM</td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>
<tr>
<td colspan="2">00000221</td>
<td colspan="2">Employee Name 6</td>
<!--<td colspan="2"></td> -->
<td colspan="2"></td>
<td colspan="2"></td>
<!--<td colspan="2"></td>-->
<!-- <td colspan="2"></td> -->
</tr>[/code]


Does that template get cached and are you sure you're making changes to the correct file?

There are some uncommented html tags in the source code that is not in PHP.
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — Yes....I put the code you suggested in correct file..

I don't know why it happens


Thank you
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — That's why it has a uncommented file...because in the code that i post.. i remove the uncommented files, but in my real code it has..
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — Now, the LOGIN td has a color red...but my logout has also a NULL value...

but it has no color red


Thank you
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — Is it red from the changes I suggested earlier? If it is then we will need to add an extra check for logout in the sql statement and also add it to your smarty template.
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — Yes, I do that and it work

Thank you
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — So basically, this should do the trick:

SQL
[CODE]$sql = "SELECT [COLOR="Red"]IF(ISNULL(a.LOGIN), 'rdc', '') AS LOGIN_CLASS, IF(ISNULL(a.LOGOUT), 'rdc', '') AS LOGOUT_CLASS,[/COLOR] a.EMP_NO, CONCAT(LNAME, ', ' , FNAME, ' ', MI) AS FULLNAME, a.LOGIN, a.LOGOUT
FROM $ATTENDANCE.employee_attendance AS a LEFT JOIN $ADODB_DB.employment em ON a.EMP_NO = em.EMP_NO
LEFT JOIN $ADODB_DB.personal p ON em.EMP_ID = p.EMP_ID WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'
AND em.STATUS IN ('Reg Operatives', 'Reg Staff ') OR LOGIN IS NULL";[/CODE]


RegAttendance.tpl
[CODE] ...

{section name=att loop=$attendance}
<tr>
<td colspan="2">{$attendance[att].EMP_NO}</td>
<td colspan="2">{$attendance[att].FULLNAME}</td>

<!--<td colspan="2">{$attendance[att].TimeIn}</td> -->
<td colspan="2" [COLOR="red"]class="{$attendance[att].LOGIN_CLASS}"[/COLOR]>{$attendance[att].LOGIN|date_format:"&#37;d-%m-%Y %I:%M %p"}</td>
<td colspan="2" [COLOR="red"]class="{$attendance[att].LOGOUT_CLASS}"[/COLOR]>{$attendance[att].LOGOUT|date_format:"%d-%m-%Y %I:%M %p"}</td>
<!--<td colspan="2">{$attendance[att].TimeOut|date_format:"%d-%m-%Y %I:%M %p"}</td>-->
<!-- <td colspan="2">{$attendance[att].TimeOut}</td> -->
</tr>
{sectionelse}
<tr><td colspan="1">No DATA</td></tr>
{/section}

...[/CODE]
Copy linkTweet thisAlerts:
@newphpcoderauthorDec 24.2011 — yeah...

It works...


Thank you so much...
Copy linkTweet thisAlerts:
@bionoidDec 24.2011 — Cool ?
×

Success!

Help @newphpcoder spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...