Posts

Showing posts from May, 2021

How to: Display Data from Database in Pagination

1. Please refer to this post to display data in table 2. After displaying them in the table, follow the instructions attached on the comment section (//) :   //determine no of data to display per page $results_per_page = 10; //count all column from the database $sql = "SELECT COUNT(*) FROM test_user"; $res = $dbx->query($sql); $count = $res->fetchColumn(); // determine no of total pagination needed by dividing no of total columns ($count) with total data to display (10) $number_of_pages = ceil($count/$results_per_page); // determine which page number visitor is currently on if(!isset($_GET['page'])){     $page = 1; }else{     $page = $_GET['page']; } // determine the sql LIMIT starting number for the results on the displaying page $this_page_first_result = ($page-1)*$results_per_page;                          $sql = "SELECT id, user_email, user_fullname, user_address, user_city, user_zip, user_state, user_country, user_tel, user_fax from test_user

How to: Display Data from SQL Database in HTML Table - Bootstrap 5

Image
The above picture refers to the table displaying the information from an SQL database. *note: this tutorial is using Bootstrap 5 (CSS Framework) & PDO (PHP Data Object) 1. Set connection to the database <?php require_once('core.php') ?> 2. Write HTML <table>      <div class="data">              <div class="row">             <div class="col-lg-12">                 <div class="table-responsive">                     <table class="table table-striped table-hover">                     <thead>                     <tr>                         <th scope="col">ID</th>                         <th scope="col">Email</th>                         <th scope="col">Full Name</th>                         <th scope="col">Address</th>                         <th scope="col">City</th>