- pagination/ PHPSense Pagination Class
- <?php
- echo '<h1>Customers:</h1>';
- include ('ps_pagination.php');
- //Make the Database Connection
- $conn = mysqli_connect ("db", "username", "password", "dbname") OR die ('Could not connect to MySQL:' .mysqli_connect_error() );
- $sql = "SELECT CONCAT(left(FirstName,1),left(MiddleName,1),LastName) AS UserName,
- CONCAT(LastName, ', ', FirstName, ' ', MiddleName) AS Name,
- (NewCustomerID) AS customerid,
- (OldCustomerID) AS oldcustomerid,
- (zlu_birthmonth.Description) AS birthmonth,
- (zlu_cars.Description) AS cartype,
- (zlu_carcolor.Description) AS carcolor,
- (zlu_computers.Description) AS computer,
- (zlu_race.Description) AS race,
- (zlu_residence.Description) AS residence,
- (IsLaptop) AS IsLaptop,
- CASE IsLaptop
- WHEN '1' THEN 'Yes'
- WHEN '0' THEN 'No'
- END AS laptop
- FROM customer
- INNER JOIN zlu_cars ON(customer.CarID = zlu_cars.CarID)
- INNER JOIN zlu_birthmonth ON(customer.BirthMonthID = zlu_birthmonth.BirthMonthID)
- INNER JOIN zlu_carcolor ON (customer.CarColorID = zlu_carcolor.CarColorID)
- INNER JOIN zlu_computers ON (customer.ComputerID = zlu_computers.ComputerID)
- INNER JOIN zlu_race ON(customer.RaceID = zlu_race.RaceID)
- INNER JOIN zlu_residence ON(customer.ResidenceID = zlu_residence.ResidenceID)
- order by NewCustomerID ";
- $pager = new PS_Pagination($conn, $sql,10,7);
- $rs=$pager->paginate();
- echo '<table border="1" bgcolor="#eeeeee">
- <tr>
- <th>Customer ID</th>
- <th>Old Customer ID</th>
- <th>Customer Name</th>
- <th>UserName</th>
- <th>Car</th>
- <th>Car Color</th>
- <th>Birth Month</th>
- <th>Computer Brand</th>
- <th>Laptop</th>
- <th>Race</th>
- <th>Residence</th>
- </tr>';
- $bg = '#eeeeee'; // set initial back ground color
- $r = @mysqli_query($conn, $sql); if(!$r){die(mysqli_error($conn));}
- while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
- $bg = ($bg =='#eeeeee' ? '#ffffff' : '#eeeeee'); // switch the background color.
- echo '<tr bgcolor="' . $bg . '">
- <td>' . $row['customerid']. '</td>
- <td>' . $row['oldcustomerid']. '</td>
- <td>' . $row['Name'].'</td>
- <td>' . $row['UserName'].'</td>
- <td>' . $row['cartype'].'</td>
- <td>' . $row['carcolor'].'</td>
- <td>' . $row['birthmonth'].'</td>
- <td>' . $row['computer'].'</td>
- <td>' . $row['laptop'].'</td>
- <td>' . $row['race'].'</td>
- <td>' . $row['residence'].'</td>
- </tr>'; }
- echo '</table>';
- echo $pager->renderFullNav();
- ?>