vendredi 17 juin 2016

PHP MySQL Results Filter By Phone Calls Only

I have a PHP Last actioned list that pulls results from mysql and displays the data but I need to define it by only Phone calls. the MYSQL field is "type" and phone call is "P"

Example filter date > $type = P

<?php
$db_host = "hidden";
$db_user = "hidden";
$database= "hidden";
$db_pwd= "hidden";
$conn = mysql_connect($db_host, $db_user, $db_pwd) or die(mysql_error());
mysql_select_db($database, $conn) or die(mysql_error());
$epoch = date('U');
$dayEnd = strtotime("midnight", $epoch);
$dayStart   = strtotime("tomorrow", $dayEnd) - 1;
$query = mysql_query("select FROM_UNIXTIME(a.maxepoch,"%d-%m-%Y") ,  b.id, b.sid, b.did,  b.type, b.nextaction, FROM_UNIXTIME(b.nextactiondate,"%d-%m-%Y") from History b,
(select  max(epoch) as maxepoch  from History
group by did) a
#where a.maxepoch = b.epoch and b.epoch < (unix_timestamp(now()) - 2592000)
where a.maxepoch = b.epoch and b.epoch < (unix_timestamp(now()) - 2419200)
order by b.epoch desc");
$mydate = date("d-m-Y");
$message = "<br><br><h1>30 day Report for $mydate</h1><br>";
$message .= "<table border="1"><tr><strong><td>Client Ref</td><td>Customer Ref</td><td>Action</td><td>Action Date</td><td>Next Action</td><td>Next Action Date</td></strong></tr>";
while ($def = mysql_fetch_row($query)) {
    $sid = $def[2];
    $did = $def[3];
    $type = $def[4];
    $nextaction = $def[5];
    $nextactiondate = $def[6];
    $maxepoch = $def[0];
$message .= "<tr><td>$sid</td><td>$did</td><td>$type</td><td>$maxepoch</td><td>$nextaction</td><td>$nextactiondate</td></tr>";
  } 
  mysql_free_result($query);
  mysql_close($conn);
  $message .= "</table>";
  $message .= "</body></html>";
echo $message;
?>

Aucun commentaire:

Enregistrer un commentaire