Problem with an automatic loader
Posted: 17 Jan 2018, 19:33
Hello i`m busy with an notification-system, but i have a problem in my automatic-loader.
It does not show $users[id] on the second &nd furter pages
I hope you could help me out.
It does not show $users[id] on the second &nd furter pages
I hope you could help me out.
Code: Select all
<?php
//Database config detail
define('_HOST_NAME','127.0.0.1');
define('_DATABASE_NAME','comments');
define('_DATABASE_USER_NAME','comments');
define('_DATABASE_PASSWORD','123456');
$id = (int) $_GET['id'];
$dbConnection = new mysqli(_HOST_NAME, _DATABASE_USER_NAME, _DATABASE_PASSWORD, _DATABASE_NAME);
if ($dbConnection->connect_error) {
trigger_error('Connection Failed: ' . $dbConnection->connect_error, E_USER_ERROR);
}
//item per page
$limit = 2;
$page =(int)(!isset($_GET['p']))?1: $_GET['p'];
// sql query
$sqlContent="SELECT * FROM `alert` WHERE context='$users[id]' ORDER BY `id` DESC";
//Query start point
$start =($page * $limit)- $limit;
$resContent=$dbConnection->query($sqlContent);
$rows_returned = $resContent->num_rows;
// query for page navigation
if( $rows_returned > ($page * $limit)){
$next =++$page;
}
$sqlContent = $sqlContent ." LIMIT $start, $limit";
$finalContent = $dbConnection->query($sqlContent);
if($finalContent === false) {
trigger_error('Error: ' . $dbConnection->error, E_USER_ERROR);
} else {
$rows_returned = $finalContent->num_rows;
}
?>