How to write a function when called it is displayed in the different table based on the date..
function name($start_dt,$end_dt){
$records=array();
if($end_dt!=""){
$res_date=mysql_query("select distinct(date(timestamp)) from head_table where date(timestamp)>= '".$start_dt."' and date(timestamp) <= '".$end_dt."'");
//$res1=mysql_query($res_date);
}
else {
$res_date=mysql_query("select distinct(date(timestamp)) from head_table where date(timestamp) = '".$start_dt."'");
}
$date=array();
//while($res2=mysql_fetch_array($res_date)){
while($row = mysql_fetch_array($res_date))
{
array_push($date,$row[0]);
}
foreach($date as $_)
{
$res_head="select distinct(headname) from head_table where date(timestamp)='".$_."' and status=0";
$result = mysql_query($res_head);
$head_node = array();
while($res = mysql_fetch_array($result)){
array_push($head_node,$res[0]);
}
foreach($head_node as $head){
$ping_status = array();
// $datevalues = array();
$sql = "SELECT status,timestamp,headname FROM head_table WHERE headname='".$head."' and date(timestamp)='".$_."'";
$row = mysql_query($sql);
$previousStatus = '';
$currentStatus = '';
$previoustime='';
$currentTime='';
while($result = mysql_fetch_array($row))
{
$currentStatus = $result['ping_status'];
$currentTime = $result['timestamp'];
$previousStatus = $previousStatus == '' ? $currentStatus : $previousStatus;
$previoustime = $previoustime == '' ? $currentTime : $previoustime;
$value = array(0,0,0,0,0,0);
$q=0;
if($previousStatus == $currentStatus)
{
$previousStatus=$currentStatus;
continue;
}
$d = strtotime($currentTime) - strtotime($previoustime);
array_push($values,".......................................................");
$previousStatus = $currentStatus;
$previoustime=$currentTime;
}
}
}
return $value;
}