I have the below php script working if you use one condition (if..else works fine) If try to use if and else if statement( because of two conditions are true) the second one is working and not the first one.
Script:
$damage_topdir = "/ids_images/drsIN2/";
$damage_topdir1 = "/ids_images/drsIN1/";
$tmp = split(" ", $displayEntryDatetime);
$date = $tmp[0];
$time = $tmp[1];
$tmp = split("/", $date);
$day = $tmp[0];
$month = $tmp[1];
$year = $tmp[2];
$displayEntryDatetime = $year."-".$month."-".$day." ".$time;
$cam_list = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
if ($cam = 'DRHdrsIN1')
{
foreach ($cam_list as $cam) {
$timestamp = strtotime($displayEntryDatetime);
$cam_delta =6;
$timestamp = $timestamp - $cam_delta;
for ($i = 0; $i < $cam_delta+20; $i++) {
$cdate = date("d_m_Y* H_i_s", $timestamp);
$image_name = "/xampp/htdocs" . $damage_topdir. $cam . "/Cam*" . $cam . "*-" .$cdate . "*";
foreach (glob($image_name) as $filename) {
if (file_exists($filename)) {
$fs_image = str_replace("/xampp/htdocs", "", $filename);
print "<h3>Camera $cam</h3>";
print "<a href=\"$fs_image\" target=\"_new\"><img src=\"$fs_image\" height=240 width=320 /></a>\n";
}
}
$timestamp++;
}
}
}
elseif($cam = 'DRHdrsIN2') ----> this one executes normally...
{
foreach ($cam_list as $cam) {
$timestamp = strtotime($displayEntryDatetime);
$cam_delta = 6;
$timestamp = $timestamp - $cam_delta;
for ($i = 0; $i < $cam_delta+20; $i++) {
$cdate = date("d_m_Y* H_i_s", $timestamp);
$image_name = "/xampp/htdocs" . $damage_topdir1. $cam . "/Cam*" . $cam . "*-" .$cdate . "*";
foreach (glob($image_name) as $filename) {
if (file_exists($filename)) {
$fs_image = str_replace("/xampp/htdocs", "", $filename);
print "<h3>Camera $cam</h3>";
print "<a href=\"$fs_image\" target=\"_new\"><img src=\"$fs_image\" height=240 width=320 /></a>\n";
}
}
$timestamp++;
}
}
}
else {
}
?>