<?php 
include "scrinit.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require("dbconnect.php");
    $logos=$_POST['logos'];
	$taxi=$_POST['tax'];
	$mitr=$_POST['mitr'];
	echo count($mitr);
	$d1=$_POST['d1'];
	$d2=$_POST['d2'];
	$i=0;
	foreach ($logos as $l)
	{
		$arr=explode("/",$l);
		$r=$arr[0];
		$m=$arr[1];
		if (in_array($m,$mitr))
		{
			
			$dout=$d1[$i];
			$din=$d2[$i];
			$q=mysqli_query($con,"select * from spiticovid where mitroo='$m'");
			if (mysqli_num_rows($q) == 0)
			{
				//echo "insert".$m;
				$qv1="insert into spiticovid (mitroo,dateout,dateback,reason) values ('$m','$dout','$din','$r')";
				if (!mysqli_query($con, $qv1)) 
				{
		            echo "Error: " .$qv1. "<br>" . mysqli_error($con);
				}
			}
			else
			{
				//echo "update".$m;
				$qv2="update spiticovid set dateout='$dout',dateback='$din',reason='$r' where mitroo='$m'";
				if (!mysqli_query($con, $qv2)) 
				{
		            echo "Error: " .$qv2. "<br>" . mysqli_error($con);
				}
			}
		}
		else
		{
			//echo "delete".$m;
			$qvd="delete from spiticovid where mitroo='$m'";
				if (!mysqli_query($con, $qvd)) 
				{
		            echo "Error: " .$qvd. "<br>" . mysqli_error($con);
				}
		}

		$i++;
	}

header("Location:covidlist.php?taxi=".$taxi);
?>
<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>
