Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername ="localhost";
- $username = "root";
- $password = "";
- $dbname = "produ_db";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- if(isset($_GET['offset']) && isset($_GET['limit'])){
- $limit = $_GET['limit'];
- $offset = $_GET['offset'];
- $data = mysqli_query($conn, "SELECT * FROM `posts` LIMIT {$limit} OFFSET {$offset}");
- while($row = mysqli_fetch_array($data)) {
- echo '<div class="blog-post"><h1>'.$row['id'].'</h1><p>'.$row['post'].'</p></div>';
- }
- }
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement