Wednesday, March 24, 2010

PHP - Page Navigation

Done By Charitha Ranasingha

include 'session_keep.php';
include 'inc_functions.php';
include 'inc_db.php';

if(isset($_GET["index"]))
{
$index = $_GET["index"];
}


$Connect = mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Internal Error, Erro code 1, Go back and try again");
// Select database
$db_selected = mysql_select_db($DB_DBName, $Connect) or die("2");
if(!$Connect){ die ('Couldnt connect'.mysql_error());}

if(isset($index))
{

$start = $index-5;
$end = 5;

$sqlHot = 'SELECT * from job_information order by job_id limit '.$start.','.$end;
}
else
{
$sqlHot = 'SELECT * from job_information order by job_id limit 0,5';
}


$viewHot = mysql_query($sqlHot, $Connect );
if (!$viewHot) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
$num_Hot = mysql_num_rows($viewHot);

$sqlAll = 'SELECT * from job_information order by job_id';
$viewAll = mysql_query($sqlAll , $Connect );
if (!$viewAll) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
$num_All = mysql_num_rows($viewAll);





?>






Untitled Document








for ($z = mysql_num_rows($viewHot) - 1; $z >= 0; $z--)
{
if (!($a = mysql_fetch_array($viewHot)))
{
continue;
}
?>






Job Title







//echo $num_All;

$pageNum = $num_All / 5;

// echo "
".$pageNum;

// echo "
".ceil($pageNum);



for($e=1; $e<=ceil($pageNum); $e++)
{
?>








No comments:

Post a Comment