hi friends i try to add a next and previous here real coding
here i try my coding
but no result not work
help me add please, in the config file lim is add 10 so 10 messages showing in 1 page nomatter how much i dd only 10 show i want to show all help
Code:
class NewsScript
{
var $maxLength,
$lim, /* Num items to show */
$template, /* Template to use */
$db_name, /* DB Settings */
$db_host,
$db_user,
$db_password,
$connection;
/**
* Constructor, executed when we make a new object.
*
* @return NewsScript Object
*/
function NewsScript()
{
// Import Database settings etc.
require('config.php');
$this->db_host = $db_host;
$this->db_name = $db_name;
$this->db_user = $db_user;
$this->db_password = $db_password;
$this->lim = $lim;
$this->template = $template;
}
/**
* Display ALL news articles
*
*/
function displayAll()
{
$this->connect();
// Use the limit in our settings to decide how many to show
$result = mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT 0, $this->lim");
/* While we have more rows display them */
while($row = mysql_fetch_assoc($result))
{
// Display the row
$id = $row['id'];
$author = $row['author'];
$content = $row['content'];
$date = $this->convertDate($row['date']);
/*
Variables are used in the template file to display news info
*/
require($this->template);
}
$this->close();
}
/**
* Display a single news item given it's ID.
*
* @param $id - ID of item to display
* @return true/false
*/
function displayItem($id)
{
if(is_numeric($id))
{
$this->connect();
$result = mysql_query("SELECT * FROM newstbl WHERE id = '$id'");
$row = mysql_fetch_assoc($result);
$author = $row['author'];
$content = $row['content'];
$date = $this->convertDate($row['date']);
require($this->template); // Show item with our template.
$this->close();
return true;
}
else return false; // Not valid number
}
Code:
class NewsScript
{
var $maxLength,
$lim, /* Num items to show */
$template, /* Template to use */
$db_name, /* DB Settings */
$db_host,
$db_user,
$db_password,
$connection;
/**
* Constructor, executed when we make a new object.
*
* @return NewsScript Object
*/
function NewsScript()
{
// Import Database settings etc.
require('config.php');
$this->db_host = $db_host;
$this->db_name = $db_name;
$this->db_user = $db_user;
$this->db_password = $db_password;
$this->lim = $lim;
$this->template = $template;
}
/**
* Display ALL news articles
*
*/
function displayAll()
{
$this->connect();
if ($_GET['page']==NULL){
$start = 0;
} else {
$start = $_GET['page'];
}
// the if above, states that if the variable in the URL named page has a value, $start will be set to it, otherwise by default it is set to 0, meaning that it will start at the beginning of the table by default.
if($_GET['page'] < 0){
header("Location: http://site.com/news.php?page=0&lim=".$lim);
}
// Use the limit in our settings to decide how many to show
$result = mysql_query("SELECT * FROM news ORDER BY date DESC LIMIT 0, $this->lim");
/* While we have more rows display them */
while($row = mysql_fetch_assoc($result))
{
// Display the row
$id = $row['id'];
$author = $row['author'];
$content = $row['content'];
$date = $this->convertDate($row['date']);
/*
Variables are used in the template file to display news info
*/
require($this->template);
}
$previous = $start + $lim;
$next = $start - $lim;
echo "<div align='center'>
<a href='http://site.com/news.php?start=".$previous."'>Previous Page</a> -
<a href='http://site.com/news.php?start=".$next."'>Next Page</a>
</div>
";
$this->close();
}
help me add please, in the config file lim is add 10 so 10 messages showing in 1 page nomatter how much i dd only 10 show i want to show all help

thats becoz i learn @rukiya i try atleast
Comment