<?php

session_start();

    require_once('../../kompapiri/system/Database.php');
	
	require_once('../../kompapiri/system/Physis.php');

		

		$database =& DatabaseConnect::getInstance();

		$database->query("SET CHARACTER SET utf8");
		
		

for($i = 0; $i < count($_POST); $i++):

		${key($_POST)} = $_POST[key($_POST)];

		next($_POST);	

	endfor;
	

	

	
$database->setBareQuery("SELECT FirstName, LastName, SUBSTRING_INDEX(Birthday, '-', -2) FROM popular_contacts WHERE SUBSTRING_INDEX(Birthday, '-', -2) BETWEEN '".date("m-d")."' AND '".date("m-d", strtotime("+1 week"))."' ORDER BY SUBSTRING_INDEX(Birthday, '-', -2) DESC");

$name = $database->loadResultArray(0);

$surname = $database->loadResultArray(1);

$birthday = $database->loadResultArray(2);

$result = " ";

for($i = 0; $i < count($name); $i++):
if($birthday[$i] == date("m-d")){ $result.="<span class='red'>";}
$dates = explode("-", $birthday[$i]);
$result.= $dates[1].'.'.$dates[0].'. '.$name[$i].' '.$surname[$i];
if($i != count($name) - 1){ $result.=', ';}
if($birthday[$i] == date("m-d")){ $result.="</span>";}



endfor;

if($result == " "){echo ' Nema rođendana u narednih nedelju dana';} else {echo $result;}

?>



