Pull All Records from 'clients' Database Table

RECORDS
ID Name Address 1 Address 2 City State Zip Phone
1 Gorman Place 8 Horizon Road New Haven CT 06510 (336) 902-1538
2 Lavaysse Circus 27 Woodland Avenue San Mateo CA 94402 (211) 107-2844
3 Weisman Oil 3 Cindy Court Englewood NJ 07631 (276) 673-3707
4 Garrett Mag 83 Gentry Drive Melville NY 11747 (521) 333-7762
5 Carie Max Stores 236 Stanton Street Brookline MA 02446 (180) 351-8977
6 Mason Homes 587 Nathan Hale Road Bonita Springs FL 34134 (638) 895-7446
7 Bank of New York 2461 Riverside Dr. Apt. 9079 New York NY 10002 (123) 720-9779
8 Weitzman Construction 442 W. 98th St # 886 New York NY 10009 (736) 854-3262
9 Lambert Homes 841 central park west Apt. 774 St Davids PA 19087 (139) 523-8779
10 Rubin Sands 134 Iven Avenue Suite 2E New York NY 10024 (386) 634-8851
11 Rags to Riches Inc. 9739 85th Street New York NY 10003 (571) 811-5584
12 Jett Lee Sales 918 Central Ave. #313 Christiansted VI 00823 (841) 332-7923
13 Mcadams Investments Box 146 New York City NY 10003 (515) 650-2411
14 HallMark Rentals Livio Andronico 22 New York NY 10025 (534) 289-1364
15 Parson Computers 300 Knoll Blvd. Wayne NJ 07470 (279) 258-2678
16 Jenkinson Loan 8 Sundance Drive Main Road Mason MI 48920 (825) 281-8880
17 Minnick Lands 80 Hudson Street Suite 159 Bellevue WA 98004 (803) 918-7430
18 Scheiby Loans 5219 433th Ave SE Hastings-on-Hudson NY 10706 (129) 957-2662
19 Calvin Klien 32 Gray Gardens East Broadlands VA 20148 (793) 815-6116
20 Walker Floors 794 A Fairmont Ave. Hoboken NJ 07030 (351) 656-8438
21 Sherwood Oaks 1941 aberdeen way Davis CA 95616 (143) 275-2569
22 Coburn Homes 92525 N Meridian Pleasantville NY 10570 (365) 404-2548
23 Higgins Lakefront P.O. Box 664 Suite 384 Indianapolis IN 46290 (533) 230-4366
24 Davis Lodge 492 Locust Road Charlotte NC 28204 (164) 963-3123
25 Easter Travel 4114 W. Elm Suite 370 Stratham CA 03885 (330) 871-5564
26 Richman Buick PO BOX 4971 Boulder CA 80302 (131) 664-3716
27 Daly Autobody 4388 Folsom Street Suite 673 Santa Clara CA 95050 (642) 915-9286
28 Weston Electric 100 44th Ave.SE Suite 913A Glenview IL 60026 (486) 959-2036
29 Daves Diner 4585 W. Lake Norman OK 73026 (643) 147-7945
30 Eastman Rentals 600 Art Blvd. Lansing MI 48911 (158) 201-5442
31 Malcom Motors 5432 Sunset #A12 Charlotte SC 65432 (987) 543-8765

 

CODE FOLLOWS

<?php

// set error reporting to all
error_reporting(E_ALL);
include(
'includes/header.php');

// declare connection variable that is populated by the open-db file
$con '';

?>
<h1>Pull All Records from 'clients' Database Table</h1>
<!-- start of table -->
<table class="full">
    <tr>
        <th colspan=8 class="header1">
            RECORDS
        </th>
    </tr>
    <tr class="header2">
        <th>ID</th>
        <th>Name</th>
        <th>Address 1</th>
        <th>Address 2</th>
        <th>City</th>
        <th>State</th>
        <th>Zip</th>
        <th>Phone</th>
    </tr>

    <?php

    
// get all records from the 'clients' table from the database
    // open db without exposing credentials
    
include('includes/open-db.php');

    
// SQL for selecting all records from the clients table where their id is > 0
    
$query "SELECT * FROM clients WHERE id > '0' ";
    
$result mysqli_query($con$query) or die("Could not get data: $query " mysqli_error());

    
// pull out and display records from query
    
$i 0;
    while (
$row mysqli_fetch_array($result))
    {
        
$id $row['id'];
        
$name $row['name'];
        
$address_1 $row['address_1'];
        
$address_2 $row['address_2'];
        
$city $row['city'];
        
$state $row['state'];
        
$zip $row['zip'];
        
$phone $row['phone'];
        
?>

        <tr class="row<?php echo($i++ & 1); ?>">
            <td>
                <?php echo($id); ?>
            </td>
            <td>
                <?php echo($name); ?>
            </td>
            <td>
                <?php echo($address_1); ?>
            </td>
            <td>
                <?php echo($address_2); ?>
            </td>
            <td>
                <?php echo($city); ?>
            </td>
            <td>
                <?php echo($state); ?>
            </td>
            <td>
                <?php echo($zip); ?>
            </td>
            <td>
                <?php echo($phone); ?>
            </td>
        </tr>

        <?php
    
}
    
// close db
    
include('includes/close-db.php');
    
?>

</table>

<hr>

<?php

include('includes/footer.php');

?>