Jump to content

using timestamps to generate reports? how how how


CodeMama

Recommended Posts

Hi all, so I'm moving on to more complex things it seems.

I have a small db each entry is timestamped, I now need to be able to generate a report of the entries submitted that week, I have a script that creates an excel report, now I just need help with actually using the timestamp to choose 7 prior to the day the report is being run...does that make sense?

Here is the script that runs the report

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
//session_start();
include("../inc/dbconnOpen.php");

//if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){
    //header ("Location: LogOut.php");
//}

    $query = "SELECT stamp,  title,  expos, xCount,  StartDate, EndDate, advertiser  FROM textads";
    $result = mysql_query ($query) or die(mysql_error());
    $row = mysql_fetch_object ($result);
    

    $fields = mysql_num_fields($export);

    
$header = "";
$value = "";
$data = "";
    
    for ($i = 0; $i < $fields; $i++) { 
        $header .= mysql_field_name($export, $i) . "\t"; 
    } 
    
    while($row2 = mysql_fetch_row($export)) { 
        $line = ''; 
        foreach($row2 as $value) {                                             
            if ((!isset($value)) OR ($value == "")) { 
                $value = "\t"; 
            } else { 
                $value = str_replace('"', '""', $value); 
                $value = '"' . $value . '"' . "\t"; 
            } 
            $line .= $value; 
        } 
        $data .= trim($line)."\n"; 
    } 
    $data = str_replace("\r","",$data); 
    
    if ($data == "") { 
        $data = "\n(0) Records Found!\n";                         
    } 
    
    header("Content-type: application/x-msdownload"); 
    header("Content-Disposition: attachment; filename=AdDates_Report.xls"); 
    header("Pragma: no-cache"); 
    header("Expires: 0"); 
    print "$header\n$data";  
    
    
?>

:

 

Where could I use the timestamp field in the db ($stamp ) to compare it to NOW() when the report is being run...

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.