PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shivam0101
Forum Contributor
Posts: 197 Joined: Sat Jun 09, 2007 12:09 am
Post
by shivam0101 » Thu Jul 05, 2007 1:38 am
Hello,
I am using the below code to do paging
Code: Select all
function GetLinks($total,$minlimit,$limit,$file,$mstring="")
{
$limitto="";
if($mstring=="")
$mstring="minlimit";
if($total>$limit) {
if($minlimit!=0)
$firstpglink="<a href='".$file."$mstring=0&limit=$limit'>First</a>";
else
$firstpglink="<span class='contentblackbold'>First</span>";
if($limit != 0 && $total != 0) {
if($total%$limit) {
$lastcc=floor($total/$limit)*$limit;
} else {
$lastcc=(($total/$limit)-1)*$limit;
}
if($minlimit < $lastcc)
$lastpglink="<a href='".$file."$mstring=$lastcc&limit=$limit' class='greentboldlink'>Last</a>";
else
$lastpglink="<span class='greentboldlink'>Last</span>";
}
if($minlimit>=$limit) {
$prevcc=$minlimit-$limit;
$prevpglink="<a href='".$file."$mstring=$prevcc&limit=$limit' class='greentboldlink'>Previous</a>";
} else
$prevpglink="<span class='greentboldlink'>Previous</span>";
if($minlimit < (($total/$limit)-1)*$limit) {
$nextcc=$minlimit+$limit;
$nextpglink="<a href='".$file."$mstring=$nextcc&limit=$limit' class='greentboldlink'>Next</a>";
} else
$nextpglink="<span class='greentboldlink'>Next</span>";
if(($minlimit+$limit)>$total)
$limitto=$total;
else
$limitto=$minlimit+$limit;
$links[0]="<table align='center' height='55' border='0' width='100%' cellpadding='4' cellspacing='4'><tr><td>$firstpglink</td><td>$prevpglink</td><td>$nextpglink</td><td>$lastpglink</td></tr></table>";
}
else
$links[0]="";
$links[1]="Showing ".($minlimit+1)."-".$limitto." of ".$total;
return $links;
}
usage
Code: Select all
$minlimit=$_GET['minlimit'];
if(empty($minlimit)) $minlimit=0;
$row=6; $col=1;
$limit=$row*$col;
$tot=//sql statment to count the rows
$sql_search=//sql statement for search if($tot > 0)
{
<table border=1 align='center' width='100%'>
<tr><td>Photo</td> <td>Age - City - State - Country</td> <td>About me</td>
foreach($sql_search as $fetch_search)
{
//results
}
$links=($tot,$minlimit,$limit,$_SERVER['PHP_SELF']."?process=search&cond=$cond");
The problem is, as i am posting using Get method, the search conditions are appearing in the address bar. As i am posting using Get method. How can i use the above using Post method, so that the coditions won't get displayed.
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 05, 2007 7:34 am
Change the form to use the post method. Switch $_GET references to $_POST.
shivam0101
Forum Contributor
Posts: 197 Joined: Sat Jun 09, 2007 12:09 am
Post
by shivam0101 » Thu Jul 05, 2007 9:01 pm
when i click the link, its not posting
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 05, 2007 9:13 pm
Links don't post.
shivam0101
Forum Contributor
Posts: 197 Joined: Sat Jun 09, 2007 12:09 am
Post
by shivam0101 » Fri Jul 06, 2007 1:21 am
then how do i pass the values?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jul 06, 2007 1:32 am
Without Javascript's help, links can only GET.
shivam0101
Forum Contributor
Posts: 197 Joined: Sat Jun 09, 2007 12:09 am
Post
by shivam0101 » Fri Jul 06, 2007 8:00 am
How to pass the value without javascript?
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Fri Jul 06, 2007 8:24 am
If the paging isn't done by forms and buttons, just use links and _GET variables.
shivam0101
Forum Contributor
Posts: 197 Joined: Sat Jun 09, 2007 12:09 am
Post
by shivam0101 » Fri Jul 06, 2007 8:33 am
If i user $_GET, the values are visible in the addressbar.
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Fri Jul 06, 2007 8:35 am
just use a form to post your data.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Fri Jul 06, 2007 8:52 am
shivam0101 wrote: If i user $_GET, the values are visible in the addressbar.
And what variables would need to be hidden from the address bar?
shivam0101
Forum Contributor
Posts: 197 Joined: Sat Jun 09, 2007 12:09 am
Post
by shivam0101 » Fri Jul 06, 2007 9:22 am
the search conditions.
Actually i have a form in which the user will enter search conditions. If i use the POST method in form, the links wont work.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Fri Jul 06, 2007 11:57 am
Most search engines do it all through the _GET method. Search the forums. Search Google. All in the URL.
It also allows users to bookmark search results for future use.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jul 06, 2007 12:39 pm
Forum searching is provided (by default) through post here.
superdezign
DevNet Master
Posts: 4135 Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign » Fri Jul 06, 2007 1:10 pm
feyd wrote: Forum searching is provided (by default) through post here.
As far as I remember, not the paging or search queries.
Or do you mean phpBB in general?