Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2017 07:27
Show Gist options
  • Save anonymous/cf7de8400327b98631d2f6d9b23084b5 to your computer and use it in GitHub Desktop.
Save anonymous/cf7de8400327b98631d2f6d9b23084b5 to your computer and use it in GitHub Desktop.
<?php
//config_db.php
$servername = "127.0.0.1";
$username = "root";
$password = " ";
$dbname = "mydb";
$datatable = "thread"; // MySQL table name
$results_per_page = 12; // number of results per page
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} ?>
<?php
include('connfig_db.php');
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $results_per_page;
$sql = "SELECT thread.t_dp,thread.t, thread.t_id, thread.tittle, thread.t_username, thread.t_date_posting, thread.views, comments.comments, comments.comment_time, comments.comment_id, comments.c FROM ".$datatable." INNER JOIN comments ON thread.t=comments.comment_id where thread.t_type='02' LIMIT $start_from, ".$results_per_page."";
$rs_result = $conn->query($sql); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment