Querystring

Thread Solved

Join Date: Mar 2009
Posts: 23
Reputation: itsrahulk is an unknown quantity at this point 
Solved Threads: 0
itsrahulk itsrahulk is offline Offline
Newbie Poster

Querystring

 
0
  #1
20 Days Ago
Hi folks,


my url querystring is

  1. querytring.php?checkin=10/11/2009&checkout=10/01/2009&minprice=100&maxprice=200&page=1

i want to remove

  1. &page=1
from this url.

Please help

Thanks
Rahul K

They say, its not possible. Well it is, and relatively easy to accomplish!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 141
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 14
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
-1
  #2
20 Days Ago
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..

Originally Posted by itsrahulk View Post
Hi folks,


my url querystring is

  1. querytring.php?checkin=10/11/2009&checkout=10/01/2009&minprice=100&maxprice=200&page=1

i want to remove

  1. &page=1
from this url.

Please help

Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 954
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 125
ardav's Avatar
ardav ardav is offline Offline
Posting Shark
 
0
  #3
20 Days Ago
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.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 23
Reputation: itsrahulk is an unknown quantity at this point 
Solved Threads: 0
itsrahulk itsrahulk is offline Offline
Newbie Poster
 
0
  #4
20 Days Ago
Guys actually i was looking for this. apologies if you could not get me.

  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');







Originally Posted by ardav View Post
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; 20 Days Ago at 3:53 am.
Rahul K

They say, its not possible. Well it is, and relatively easy to accomplish!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 141
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 14
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
-1
  #5
20 Days Ago
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..

Originally Posted by itsrahulk View Post
Guys actually i was looking for this. apologies if you could not get me.

  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');
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 23
Reputation: itsrahulk is an unknown quantity at this point 
Solved Threads: 0
itsrahulk itsrahulk is offline Offline
Newbie Poster
 
0
  #6
20 Days Ago
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.


Originally Posted by venkat0904 View Post
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..
Rahul K

They say, its not possible. Well it is, and relatively easy to accomplish!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 954
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 125
ardav's Avatar
ardav ardav is offline Offline
Posting Shark
 
0
  #7
20 Days Ago
So it's solved?
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 23
Reputation: itsrahulk is an unknown quantity at this point 
Solved Threads: 0
itsrahulk itsrahulk is offline Offline
Newbie Poster
 
0
  #8
20 Days Ago
Yes it is. Do you know any other way ?

Originally Posted by ardav View Post
So it's solved?
Rahul K

They say, its not possible. Well it is, and relatively easy to accomplish!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 141
Reputation: venkat0904 is an unknown quantity at this point 
Solved Threads: 14
venkat0904's Avatar
venkat0904 venkat0904 is offline Offline
Junior Poster
 
-1
  #9
20 Days Ago
then wy dont u mark the thread as solved ?
Originally Posted by itsrahulk View Post
Yes it is. Do you know any other way ?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC