Page 1 of 1

PHP pageing

Posted: Thu Dec 25, 2008 7:34 pm
by kayfer
Hello PHP masters, I want to know whast the php page thing about, like ?page=2 or ?page5 something like that, I don't know for sure, I think you use less space and you work with one file, its just you hide files or something like that I just wanted to know, can you give me 1 short example.

Thank you.

Re: PHP pageing

Posted: Thu Dec 25, 2008 8:11 pm
by requinix
Less space? One file? Hide files?

Sure, we can do examples, but you have to know what you want. Maybe pagination? URL rewriting?

Re: PHP pageing

Posted: Thu Dec 25, 2008 10:03 pm
by kayfer
What you mean examples? OK here, I have 10 videos and I want to put them in one file, so if visitor clicks video 1 it shows only video one and i think on the URL it shows ?page= something like that with different numbers, but I have one file, so if I click second video and it hides first video and shows second, hide, I don't mean something like dissolve or something, it just reloads and shows ?page=2 for second video, something like that. I don't know if i explained the right thing or in clear way. Anyways thank you for help.

Re: PHP pageing

Posted: Thu Dec 25, 2008 10:08 pm
by desperado
whatever is after a question mark is a variable. it can be as simple as "hello.php?firstname=John&lastname=Doe" would print out firstname and lastname, or as complex as session information, header, footer, content, template, css, etc... there is no limit. it's usually pulled from a database. in your case, it could be a template, calling a specific page content.


answer question?

Re: PHP pageing

Posted: Thu Dec 25, 2008 11:33 pm
by kayfer
Yea but, my question was how to make those pages, to contain videos but hide them until I click to open.

Re: PHP pageing

Posted: Thu Dec 25, 2008 11:36 pm
by Christopher
These forums contain many pagination scripts discussions:

search.php?keywords=pagination&terms=al ... mit=Search

(you need to cut and paste because there are ['s in the URL)

Re: PHP pageing

Posted: Fri Dec 26, 2008 1:28 am
by pbs
Try this may this will help you. Simple pagination code

It will be like this
<< | Previous | Next | >>

Code: Select all

 
function pagingPN($sql, $page, $limit, $getvars, $class)
{
if ($page == "")
$page = 1;
if ($limit == 0)
$limit = $this->limit;
$tsql = $sql;
$result = mysql_query($tsql) or die("Error: ".mysql_errno().":- ".mysql_error());
$total = mysql_num_rows($result);
$totnumpages = ceil($total/$limit);
if ($offset < 0)
$offset = 0;
else 
$offset = ($page - 1) * $limit;
$sql = $sql. " limit $offset, $limit"; 
$res = $this->select_row($sql);
$serial_no = ($page - 1) * $limit;
 
if ($total > 0)
{
$link = ""; 
if ($page > 1)
{
$link .= "<a href=".$_SERVER['PHP_SELF']."?page=1$getvars class='".$class."' title='Jump to First Page'><<</a>&nbsp;|&nbsp;";
$prev = $page - 1;
$link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$prev."$getvars class='".$class."' title='Goto Previous Page'>Previous</a><span class='".$class."'>&nbsp;|&nbsp;</span>";
}
else
{
$link .= "<span class='".$class."' title='Jump to First Page'><<</span>&nbsp;|&nbsp;<span class='".$class."' title='Goto Previous Page'>Previous&nbsp;|&nbsp;</span>";
}
if ($page < $totnumpages)
{
$next = $page + 1;
$link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$next."$getvars class='".$class."' title='Goto Next Page'>Next</a>&nbsp;|&nbsp;";
$link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$totnumpages."$getvars class='".$class."' title='Jump to Last Page'>>></a>";
}
else
{
$link .= "<span class='".$class."' title='Goto Next Page'>Next</span>&nbsp;| <span class='".$class."' title='Jump to Last Page'>>></span>";
}
} 
$retarr["sql"] = $sql;
$retarr["records"] = $res;
$retarr["serial_no"] = $_no;
$retarr["link"] = $link;
return $retarr;
}
 

Re: PHP pageing

Posted: Fri Dec 26, 2008 2:17 am
by kayfer
Thank you for your help, but I don't get it, I am sorry but I think I need some PHP programming classes.