Page 1 of 2

paging links by posting conditions

Posted: Thu Jul 05, 2007 1:38 am
by shivam0101
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

Posted: Thu Jul 05, 2007 7:34 am
by feyd
Change the form to use the post method. Switch $_GET references to $_POST. :?

Posted: Thu Jul 05, 2007 9:01 pm
by shivam0101
when i click the link, its not posting

Posted: Thu Jul 05, 2007 9:13 pm
by feyd
Links don't post.

Posted: Fri Jul 06, 2007 1:21 am
by shivam0101
then how do i pass the values?

Posted: Fri Jul 06, 2007 1:32 am
by feyd
Without Javascript's help, links can only GET.

Posted: Fri Jul 06, 2007 8:00 am
by shivam0101
How to pass the value without javascript?

Posted: Fri Jul 06, 2007 8:24 am
by superdezign
If the paging isn't done by forms and buttons, just use links and _GET variables.

Posted: Fri Jul 06, 2007 8:33 am
by shivam0101
If i user $_GET, the values are visible in the addressbar.

Posted: Fri Jul 06, 2007 8:35 am
by aceconcepts
just use a form to post your data.

Posted: Fri Jul 06, 2007 8:52 am
by superdezign
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?

Posted: Fri Jul 06, 2007 9:22 am
by shivam0101
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.

Posted: Fri Jul 06, 2007 11:57 am
by superdezign
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.

Posted: Fri Jul 06, 2007 12:39 pm
by feyd
Forum searching is provided (by default) through post here. ;)

Posted: Fri Jul 06, 2007 1:10 pm
by superdezign
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?