Location: PHPKode > scripts > PHP Address book > php-address-book_v_1.01_eng/php-address-book_v_1.01_eng/index.php
<?php
include_once 'includes/header.inc.php'; 

if(!$session->getRole() == 1 or !$session->getRole() == 2){
    header("location: login.php");
}

?>
<legend>Coming birthdays</legend>
<?php

//from today
$date_from = date("m") . "-" . date("d");

//to 
$date_till = date("m", strtotime("+ 1 month")) . "-" . date("d");

$query = $database->query("SELECT `cal_contacts`.*, DATE_FORMAT(`cal_contacts`.`birthday`, '%d') AS `date`, DATE_FORMAT(`cal_contacts`.`birthday`, '%m') AS `month` FROM `cal_contacts` WHERE DATE_FORMAT(`cal_contacts`.`birthday`, '%m-%d') BETWEEN '$date_from' AND '$date_till' ORDER BY DATE_FORMAT(`cal_contacts`.`birthday`, '%m-%d')");

if(mysql_num_rows($query) == 0){
    ?>
    <div class="alert alert-info">
        There are no birthdays coming month
    </div>
    <?php
} else {
    ?>
    <table class="table table-striped">
        <tr>
            <th>Firstname</th>
            <th>Lastname</th>
            <th>E-mail</th>
            <th>Birthday</th>
        </tr>
    <?php
    while($row = mysql_fetch_assoc($query)){
        ?>
        <tr>
            <td><a href="<?php echo $url; ?>details.php?id=<?php echo $row['id']; ?>"><?php echo $row['firstname']; ?></a></td>
            <td><?php echo $row['lastname']; ?></td>
            <td><?php echo $row['email']; ?></td>
            <td><?php echo $row['date'] . " - " . $row['month']; ?></td>
        </tr>
        <?php
    }
}


?>
<?php include_once 'includes/footer.inc.php'; ?>
Return current item: PHP Address book