Guest User

Untitled

a guest
Apr 13th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <?php
  2. function getBookTable()
  3. {
  4.     echo "<table class='book-table' cellspacing='0'>";
  5.     $dbh = new PDO('mysql:host=localhost;dbname=baza', 'root', '');
  6.     $sql = 'SELECT * from books';
  7.     $response = $dbh->query($sql);
  8.     foreach ($response as $row) {
  9.         echo "<tr>
  10.        <td>$row[0]</td>
  11.        <td>$row[1]</td>
  12.        <td>$row[2]</td>
  13.        <td>$row[3]</td>
  14.        <td> <button onclick='deleteEntry($row[0])' >UsuĊ„ wpis</button></td>
  15.        </tr>";
  16.     }
  17.     echo "</table>";
  18.  
  19.     echo "<nav aria-label=\"Page navigation\">
  20.          <ul class=\"pagination\">
  21.            <li>
  22.              <a href=\"#\" aria-label=\"Previous\">
  23.                <span aria-hidden=\"true\">&laquo;</span>
  24.              </a>
  25.            </li>";
  26.  
  27.     $entriesCount = $response->columnCount();
  28.  
  29.     for($i = 0; $i < $entriesCount; $i++) {
  30.         echo "<li><a onclick='getPage($i)'>$i</a></li>";
  31.     }
  32.  
  33.     echo "<li>
  34.              <a href=\"#\" aria-label=\"Next\">
  35.                <span aria-hidden=\"true\">&raquo;</span>
  36.              </a>
  37.            </li>
  38.          </ul>
  39.        </nav>";
  40. }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment