Jump to content

Recommended Posts

Hello im working on a project which involves marking attendance via an RFID tag and saving the time into an sql file. Everything seems to be working fine and the time stamp is successfully punched into the SQL but something is wrong with the php code thats supposed to display this data. Please if any one can take a look and help.

 

MY CODE for displaying the data (ViewAttendance.php):

<?php
include_once("header.php");
$attData = array();
$totDays = 0;
if(isset($_REQUEST['submit'])){
	$totDays = cal_days_in_month(CAL_GREGORIAN,$_REQUEST['month'],$_REQUEST['year']);
	$attData = $commonObj->getAttendanceData($_REQUEST['month'],$_REQUEST['year']);
	//print_r($attData);
	//print_r(date("d",strtotime($attData[0]['punch_time'])));
}
?>

  
<div class="container">
<div class="row">
	<div class="col-sm-12">
	  <h4>Showing Attendance</h4>
	  <form name="showAtt" method="post">
		<div class="col-sm-4"><label>Select Month</label>
			<select name="month" class="form-control">
			  	<?php for($i=1;$i<=12;$i++){?>
			  		<option value="<?php echo $i;?>"><?php echo $i;?></option>
			  	<?php }?>
			</select>	  	
	  	</div>

		<div class="col-sm-4"><label>Select Year</label>
		  	<select name="year" class="form-control">
			  	<?php for($i=date("Y");$i>=2010;$i--){?>
			  		<option value="<?php echo $i;?>"><?php echo $i;?></option>
			  	<?php }?>
			</select>
	  	</div>
	  	<div class="col-sm-4">
	  	<p>&nbsp;</p>
	  		<input type="submit" value="Show" name="submit" class="btn btn-primary">
	  	</div>
	  </form>
	</div>
</div>
<div class="row">
	<div class="col-sm-2">
		<label class="btn btn-success btn-sm">Month:<?php echo @$_REQUEST['month'];?></label>
	</div>
	<div class="col-sm-2"><label class="btn btn-info btn-sm">Year: <?php echo @$_REQUEST['year'];?></label></div>
</div>
<div class="row">
	<div class="col-sm-12" style="overflow: scroll;">
		<?php if($totDays>0){?>
		<table class="table table-striped">
			<tr>
				<th>
					Employee Name
				</th>
				<?php for($i=1;$i<=$totDays;$i++){?>
				<th>
					<?php echo $i;?>
				</th>
				<?php }?>

				<?php foreach($attData as $attk=>$attv){
					$punchin = $commonObj->getTimeOfDate($attData[$attk]['punchin']);
							$punchout = $commonObj->getTimeOfDate($attData[$attk]['punchout']);
					?>
				<tr>
					<th class="danger">
						<?php echo $attv['name'];?>
					</th>
					<?php for($i=1;$i<=$totDays;$i++){?>
					
						<?php if($commonObj->getDayOfDate($attData[$attk]['punch_time']) == $i){
							
							echo "<td class='success' id='att_$i'>".$punchin.'-'.$punchout;?>
							<table class="table table-responsive"style="display: none; position:relative;min-width:100px;max-width:200px; margin-top: -40px;" id="<?php echo "det_att_".$i;?>">
								<tr>
								<td>Total hours:</td>
								<td><?php echo $commonObj->getHoursBetweenDates($attData[$attk]['punchin'],$attData[$attk]['punchout']);?>
								</td></tr>
								<tr>
									<td>UID:</td>
									<td><?php echo $attData[$attk]['rfid_uid'];?></td>
								</tr>
							</table>
							<?php
							}else {echo "<td class='info'>#na";}?>
					</td>
					<?php }?>
				</tr>
				<?php }?>
			</tr>
		</table>
		<?php }?>
	</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
	$("td").hover( 
		
		function () {
			var id = "#det_"+this.id;
                  $(id).css({"display":"block"});
               }, 
				
               function () {
               	var id = "#det_"+this.id;
                  $(id).css({"display":"none"});
               
		
		//console.log(id);
		//$(id).css("display","block");
		
	});

});
</script>

Display of (ViewAttendance.php):

PHlUhGu.png

MY SQL TABLE :

m4vg5NC.png

Link to comment
https://forums.phpfreaks.com/topic/309513-data-not-displaying/
Share on other sites

10 minutes ago, Jason92 said:

but something is wrong with the php code thats supposed to display this data

Perhaps you could give us a clue

  • What is it doing that it shouldn't do
  • What is it not doing that it should do?
Link to comment
https://forums.phpfreaks.com/topic/309513-data-not-displaying/#findComment-1571472
Share on other sites

2 minutes ago, Barand said:

Perhaps you could give us a clue

  • What is it doing that it shouldn't do
  • What is it not doing that it should do?

Its suppose to display the list of employees with their timings. Its isnt displaying that. just an empty table as shown in the picture.

Link to comment
https://forums.phpfreaks.com/topic/309513-data-not-displaying/#findComment-1571473
Share on other sites

Your HTML <table> is messed up. Your missing </tr> tags and using a table in a table is not the way to go when what you want can be done using css tooltips.

If you run your code for a simple query and post the html resulting and explain it, I or someone else could give you the needed table code. Also tell us where the cursor is to get the output.

Link to comment
https://forums.phpfreaks.com/topic/309513-data-not-displaying/#findComment-1571483
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.