Reports not displaying properly


#1

Iam trying to display the reports between two dates. It is not fetching the data correctly. I am using php with excel. If any of you had the same problem and got it rectified, please let me know.

Thanks
Rekha


#2

Need code to be able to help you do anything…


#4
<?php
 echo '<link rel="stylesheet" type="text/css" href="report.css"></head>'; 
 $fd = date('d/m/y',$_POST['fd']);
 $ld = date('d/m/y', $_POST['ld']);
$fd=$_POST['fd'];
 $td=$_POST['ld'];

echo $fd;
echo 'second';
echo $td;
$file1 = fopen("contacts.csv","r");

$array=file('contacts.csv');
foreach ($array as $key=>$var)
{
$array[$key]=explode(',',$var);
}
echo "<div class='row'>
";
echo "<h2 align='center' class='blue'> Today's Records </h2>";
echo '<table class="samples">';
echo '<tr><th>Date</th>
<th>Firstname</th>
    <th>Email</th> 
    <th>Designation</th>
	<th>Department</th>
    <th>Mobile Number</th>
	<th>Landline Number</th>
	<th>Address</th>
	<th>Machine Make</th>
	<th>Model/Product Code</th>
	<th>Service No.</th>
	<th>Express Code</th>
	<th>Problem Description</th>
  </tr>';
 echo $fd;
   echo $td;
foreach ($array as $key=>$value)

{  
  $i++;
  echo $i;
   echo '<tr class=d' . ($i & 1) . ' align="center">';
 //  $rd=date('d/m/y',strtotime($array[$key][0]));
 
  $rd=date('d/m/y',strtotime($array[$key][0]));
   /* if date('d/m/y',strtotime($array[$key][0]))>=$fd && date('d/m/y',strtotime($array[$key][0]))<=$td)*/
	
	if (date('d/m/y',strtotime($array[$key][0]))>$fd && date('d/m/y',strtotime($array[$key][0]))<$td)
  {
  $i1++;
  echo $rd;
  echo date('d/m/y',strtotime($array[$key][0]));
 
  echo '<td class="w">' . $array[$key][0] . '</td>';
  echo '<td>' . $array[$key][1] . '</td>';
  echo '<td>' . $array[$key][2] . '</td>';
  echo '<td>' . $array[$key][3] . '</td>';
  echo '<td>' . $array[$key][4] . '</td>';
  echo '<td>' . $array[$key][5] . '</td>';
  echo '<td>' . $array[$key][6] . '</td>';
  echo '<td>' . $array[$key][7] . '</td>';
  echo '<td>' . $array[$key][8] . '</td>';
  echo '<td>' . $array[$key][9] . '</td>';
  echo '<td>' . $array[$key][10] . '</td>';
  echo '<td>' . $array[$key][11] . '</td>';
  echo '<td>' . $array[$key][12] . '</td>';
  }
}
echo '</table>';

?>

#5

What isn’t being fetched properly?

https://www.w3schools.com/php/func_filesystem_fgetcsv.asp


#6

it is displaying the records but the records within the dates are not displaying
It is showing the wrong records


#7

image

In the image I tried to display the records between dec. 20th and jan 4th
but it is displaying august records

That is my problem


#8

Why are you doing $array[$key]? If you want to go that route, use a for loop, otherwise you are not using the foreach properly.

What is the index of the key with the date? Or a subset of sample data so we can show you how.


#9

$array[$key][0] is the index of date