Location: PHPKode > scripts > PHP Address book > php-address-book_v_1.02_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 = $mysqli->prepare("SELECT 
                                `cal_contacts`.`id`, 
                                `cal_contacts`.`firstname`, 
                                `cal_contacts`.`lastname`, 
                                `cal_contacts`.`email`, 
                                `cal_contacts`.`phone_home`, 
                                `cal_contacts`.`phone_cell`, 
                                `cal_contacts`.`address`, 
                                `cal_contacts`.`zipcode`, 
                                `cal_contacts`.`city`, 
                                `cal_contacts`.`birthday`,
                                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 
                                ? AND ? 
                           ORDER BY 
                                DATE_FORMAT(`cal_contacts`.`birthday`, '%m-%d')
                           ");
$query->bind_param(dd, $date_from, $date_till);
$query->bind_result($q_id, $q_firstname, $q_lastname, $q_email, $q_phone_home, $q_phone_cell, $q_address, $q_zipcode, $q_city, $q_birthday, $q_date, $q_month);
$query->execute();

if($query->affected_rows == 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($query->fetch()){
        ?>
        <tr>
            <td><a href="<?php echo $url; ?>details.php?id=<?php echo $q_id; ?>"><?php echo $q_firstname; ?></a></td>
            <td><?php echo $q_lastname; ?></td>
            <td><?php echo $q_email; ?></td>
            <td><?php echo $q_date . " " . $q_month; ?></td>
        </tr>
        <?php
    }
}
$query->store_result();


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