944,113 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 651
  • PHP RSS
Nov 6th, 2009
0

Querystring

Expand Post »
Hi folks,


my url querystring is

PHP Syntax (Toggle Plain Text)
  1. querytring.php?checkin=10/11/2009&checkout=10/01/2009&minprice=100&maxprice=200&page=1

i want to remove

PHP Syntax (Toggle Plain Text)
  1. &page=1
from this url.

Please help

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
itsrahulk is offline Offline
23 posts
since Mar 2009
Nov 6th, 2009
0
Re: Querystring
well i dont understand ur problm vry well but i think u can remove that piece of info from the php code where u r generating that query string...
Please elaborate ur problem and paste code if possible in order to get better clarification.
I guess u r using some1 else's code..

Click to Expand / Collapse  Quote originally posted by itsrahulk ...
Hi folks,


my url querystring is

PHP Syntax (Toggle Plain Text)
  1. querytring.php?checkin=10/11/2009&checkout=10/01/2009&minprice=100&maxprice=200&page=1

i want to remove

PHP Syntax (Toggle Plain Text)
  1. &page=1
from this url.

Please help

Thanks
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009
Nov 6th, 2009
-1
Re: Querystring
IS the 'page' parameter actually doing anything? You could just not set it in the first place. OR you could just ignore it, i.e. not have $_GET['page'] do anything. Once the 'page' has been passed to the new page, even if you remove the bit with str_replace() or similar, $_GET['page'] will still exist. You could get rid of it by unset($_GET['page']).

If you really need to get rid of the offending parameter and can't do this from the original parsing function, use str_pos() to find the start of '&page=' and str_replace() to replace all characters from that point onwards with '' OR use str_pos() and substr() to truncate from that point onwards.
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 954
Disgraced Poster
ardav is offline Offline
6,727 posts
since Oct 2006
Nov 6th, 2009
0
Re: Querystring
Guys actually i was looking for this. apologies if you could not get me.

PHP Syntax (Toggle Plain Text)
  1. function remove_querystring_var($url, $key) {
  2. $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
  3. $url = substr($url, 0, -1);
  4. return ($url);
  5. }
  6.  
  7. echo remove_querystring_var($_SERVER['QUERY_STRING'],'page');







Click to Expand / Collapse  Quote originally posted by ardav ...
IS the 'page' parameter actually doing anything? You could just not set it in the first place. OR you could just ignore it, i.e. not have $_GET['page'] do anything. Once the 'page' has been passed to the new page, even if you remove the bit with str_replace() or similar, $_GET['page'] will still exist. You could get rid of it by unset($_GET['page']).

If you really need to get rid of the offending parameter and can't do this from the original parsing function, use str_pos() to find the start of '&page=' and str_replace() to replace all characters from that point onwards with '' OR use str_pos() and substr() to truncate from that point onwards.
Last edited by itsrahulk; Nov 6th, 2009 at 3:53 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
itsrahulk is offline Offline
23 posts
since Mar 2009
Nov 6th, 2009
0
Re: Querystring
ok.. this removes the 'page' parameter from the url u pass but i m just curious whats d practical use of it? I cant see none..

Click to Expand / Collapse  Quote originally posted by itsrahulk ...
Guys actually i was looking for this. apologies if you could not get me.

PHP Syntax (Toggle Plain Text)
  1. function remove_querystring_var($url, $key) {
  2. $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
  3. $url = substr($url, 0, -1);
  4. return ($url);
  5. }
  6.  
  7. echo remove_querystring_var($_SERVER['QUERY_STRING'],'page');
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009
Nov 6th, 2009
0
Re: Querystring
actually in my project paging it being display after searching the records. records are being paged.so there is a long query string which i can't assembe using the $_GET[] , so i used the server varialbe $_SERVER['QUERY_STRING'], which in turn apending the page variable again and again in the url querystring while moving over the pages, to remove this problem i thought i must remove this page varialbe so that page class again can append it's page parameter only once.

if you know some better way of doing it kindly suggest me

Thanks.


Click to Expand / Collapse  Quote originally posted by venkat0904 ...
ok.. this removes the 'page' parameter from the url u pass but i m just curious whats d practical use of it? I cant see none..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
itsrahulk is offline Offline
23 posts
since Mar 2009
Nov 6th, 2009
-1
Re: Querystring
So it's solved?
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 954
Disgraced Poster
ardav is offline Offline
6,727 posts
since Oct 2006
Nov 6th, 2009
0
Re: Querystring
Yes it is. Do you know any other way ?

Click to Expand / Collapse  Quote originally posted by ardav ...
So it's solved?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
itsrahulk is offline Offline
23 posts
since Mar 2009
Nov 6th, 2009
-1
Re: Querystring
then wy dont u mark the thread as solved ?
Click to Expand / Collapse  Quote originally posted by itsrahulk ...
Yes it is. Do you know any other way ?
Reputation Points: 13
Solved Threads: 21
Junior Poster
venkat0904 is offline Offline
186 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: session time out in php
Next Thread in PHP Forum Timeline: PHP Web FTP Software





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC