Jump to content

Problem in NULL value

- - - - -

  • Please log in to reply
3 replies to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 474 posts
Hi...
i have table
EMP_NO
LOGIN - DATETIME, NULL
LOGOUT - DATETIME, NULL

I have this query:


<?php


include 'config.php';


$currentEmpID = $_SESSION['empID']; 

 

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

     

    $DATE1 = $_POST['firstinput'];

    $DATE2   = $_POST['secondinput'];

    

  

 $sql = "SELECT EMP_NO, LOGIN, LOGOUT  FROM employee_attendance WHERE DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2'";

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

   

    $smarty->assign('attendance', $attendance);


 }

 $smarty->display('header_att.tpl');

 $smarty->display('empAttendance.tpl');

 $smarty->display('footer.tpl');

  

?> 


My problem is I have data
EMP_NO 00000223
LOGIN NULL
LGOUT NULL

this data was not displayed because it has a null value.. i want it to displayed also and highlight it because it has a value null..

Thank you

#2
Gerg? Magyar

Gerg? Magyar

    Newbie

  • Members
  • PipPip
  • 22 posts

$sql = "SELECT EMP_NO, LOGIN, LOGOUT  FROM employee_attendance WHERE DATE(LOGIN) BETWEEN #{$DATE1}# AND #{$DATE2}#";



#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
"SELECT EMP_NO, LOGIN, LOGOUT FROM employee_attendance WHERE (DATE(LOGIN) BETWEEN '$DATE1' AND '$DATE2') or LOGIN IS NULL
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 474 posts
This is my new code...my problem now is highlighting with null values


Now also I need to highlight the data which has a NULL value.

I have this revised code:

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

 $DATE1 = $_POST['Regfirstinput'];    

 $DATE2   = $_POST['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){ // I dont know how can I add stylesheet here so that if it has a NULL value it will have a background color RED

}      

 $smarty->assign('attendance', $DTR); }



<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>


Thank you




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users