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

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

$id = $_GET['id'];



$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-%m-%Y') as `date_trans` 
                           FROM 
                                `cal_contacts` 
                           WHERE 
                                `id` = ?");
$query->bind_param(i, $id);
$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_trans);
$query->execute();

while($row = $query->fetch()){
    $firstname = $q_firstname;
    $lastname = $q_lastname;
    $email = $q_email;
    $phone_home = $q_phone_home;
    $phone_cell = $q_phone_cell;
    $address = $q_address;
    $zipcode = $q_zipcode;
    $city = $q_city;
    $birthday = $q_birthday;
}
$query->store_result();
?>
<legend>Detailed view</legend>
<div class="span6">
    <table class="table table-striped">
        <tr>
            <th>Firstname</th>
            <td><?php echo $firstname; ?></td>
        </tr>
        <tr>
            <th>Lastname</th>
            <td><?php echo $lastname; ?></td>
        </tr>
        <tr>
            <th>E-Mail</th>
            <td><?php echo $email; ?></td>
        </tr>
        <tr>
            <th>Phone (home)</th>
            <td><?php echo $phone_home; ?></td>
        </tr>
        <tr>
            <th>Phone (cell)</th>
            <td><?php echo $phone_cell; ?></td>
        </tr>
        <tr>
            <th>Address</th>
            <td><?php echo $address; ?></td>
        </tr>
        <tr>
            <th>Zipcode</th>
            <td><?php echo $zipcode; ?></td>
        </tr>
        <tr>
            <th>City</th>
            <td><?php echo $city; ?></td>
        </tr>
        <tr>
            <th>Date of birth</th>
            <td><?php echo $birthday; ?></td>
        </tr>
    </table>
    <a href="<?php echo $url; ?>edit.php?id=<?php echo $id; ?>" class="btn">Edit</a>
    <a href="<?php echo $url; ?>delete.php?id=<?php echo $id; ?>" class="btn">Delete</a>
</div>
<div class="span4">
    <input type="text" id="address" value="<?php echo $address . ", " . $city; ?>" style="display: none;"/>
    <script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    function initialize(address) {
            var geoCoder = new google.maps.Geocoder(address)
            var request = {address:address};
            geoCoder.geocode(request, function(result, status){
                    var latlng = new google.maps.LatLng(result[0].geometry.location.lat(), result[0].geometry.location.lng());
                    var myOptions = {
                    zoom: 17,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
            var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
                    var marker = new google.maps.Marker({position:latlng,map:map,title:'title'});
            })
    }
    
    $(document).ready(function(){
        var addr = $("#address").val();
        initialize(addr);
    })
    </script>
    <div id="map_canvas"></div>
</div>

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