RE: [PHP] Dealing with Query String

2002-04-09 Thread Maxim Maletsky



In your PHP:

On every click collect two variables: 

$by and $order 

then, call for this query:

Select field from table where this=that order by $by $order;


Make sure both variables have their default values in case there was
nothing selected.
You don't really need a function for this, just a few variables preset
before calling mySQL.



Do pobachennya,

Maxim Maletsky
Founder, Chief Developer

PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com



 -Original Message-
 From: Vladislav Kulchitski [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 10, 2002 3:49 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Dealing with Query String
 
 
 Hi,
 
 I need some help with query string. Basically what I am doing is I am
 sorting my table, much like you sort columns in OUTLOOK EXPRESS for
 instance with a little arrow...
 

http://www.kulchitski.com/btl/btl.php?lang=engpage=talkroom_showsort=s
 ex
 
 So all I need a function that will grab this query and will change
sort=
 and another new variable (desc/asc) and will return the same string
but
 with new values for certain variables... I ran across some function
like
 this before when Ididn't need it, but just now when I need it badly -
 can't seem to be able to find it. Hope someone out there can help.
 
 Thank you much.
 Vlad
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Dealing with Query String

2002-04-09 Thread Vladislav Kulchitski

Privit Maxim,

I understand your approach... i.e. I can hardcode it in the links, but
what if I will add more variables in a query string... note in the query
string there are variables that are not really related to the operation
with the table, rather language ($lang=), page ($page=)... for now I
guess I will wind up doing it HARD-CODEed way...

Thanks,
Vlad
p.s. if anyone knows how to solve my problems, let me know... I think
the function that would be suitable is parse_str() less suitable but
still doable would be explode()...
p.p.s. for MAXIM: I am doing it with languages switching as you can see
on the top of the template.. I am using explode()

-Original Message-
From: Maxim Maletsky [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, April 09, 2002 10:04 PM
To: Vladislav Kulchitski; [EMAIL PROTECTED]
Subject: RE: [PHP] Dealing with Query String



In your PHP:

On every click collect two variables: 

$by and $order 

then, call for this query:

Select field from table where this=that order by $by $order;


Make sure both variables have their default values in case there was
nothing selected.
You don't really need a function for this, just a few variables preset
before calling mySQL.



Do pobachennya,

Maxim Maletsky
Founder, Chief Developer

PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com



 -Original Message-
 From: Vladislav Kulchitski [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 10, 2002 3:49 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Dealing with Query String
 
 
 Hi,
 
 I need some help with query string. Basically what I am doing is I am
 sorting my table, much like you sort columns in OUTLOOK EXPRESS for
 instance with a little arrow...
 

http://www.kulchitski.com/btl/btl.php?lang=engpage=talkroom_showsort=s
 ex
 
 So all I need a function that will grab this query and will change
sort=
 and another new variable (desc/asc) and will return the same string
but
 with new values for certain variables... I ran across some function
like
 this before when Ididn't need it, but just now when I need it badly -
 can't seem to be able to find it. Hope someone out there can help.
 
 Thank you much.
 Vlad
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Dealing with Query String

2002-04-09 Thread Maxim Maletsky



Once your query (whatever it is) was composed, append this:

 order by $by $order;


so, in this example it could be looking to you something like this:

$query = 'bla bla language and page';


if(!$by) {
$by = 'name_field';

if(!$order)
$order = 'desc';
}


$query .=  $by $order;


and that is your function. It will look for $by and $order variables
passed to it via GET and will add it to your query. If not passed any it
will use the default ones. 

Just add these values to your links and that is it.
Obviously, the security there is up to you.




Sincerely,

Maxim Maletsky
Founder, Chief Developer

PHPBeginner.com (Where PHP Begins)
[EMAIL PROTECTED]
www.phpbeginner.com




 -Original Message-
 From: Vladislav Kulchitski [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 10, 2002 4:09 AM
 To: Maxim Maletsky
 Cc: [EMAIL PROTECTED]
 Subject: RE: [PHP] Dealing with Query String
 
 Privit Maxim,
 
 I understand your approach... i.e. I can hardcode it in the links, but
 what if I will add more variables in a query string... note in the
query
 string there are variables that are not really related to the
operation
 with the table, rather language ($lang=), page ($page=)... for now I
 guess I will wind up doing it HARD-CODEed way...
 
 Thanks,
 Vlad
 p.s. if anyone knows how to solve my problems, let me know... I think
 the function that would be suitable is parse_str() less suitable
but
 still doable would be explode()...
 p.p.s. for MAXIM: I am doing it with languages switching as you can
see
 on the top of the template.. I am using explode()
 
 -Original Message-
 From: Maxim Maletsky [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 09, 2002 10:04 PM
 To: Vladislav Kulchitski; [EMAIL PROTECTED]
 Subject: RE: [PHP] Dealing with Query String
 
 
 
 In your PHP:
 
 On every click collect two variables:
 
 $by and $order
 
 then, call for this query:
 
 Select field from table where this=that order by $by $order;
 
 
 Make sure both variables have their default values in case there was
 nothing selected.
 You don't really need a function for this, just a few variables preset
 before calling mySQL.
 
 
 
 Do pobachennya,
 
 Maxim Maletsky
 Founder, Chief Developer
 
 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com
 
 
 
  -Original Message-
  From: Vladislav Kulchitski [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, April 10, 2002 3:49 AM
  To: [EMAIL PROTECTED]
  Subject: [PHP] Dealing with Query String
 
 
  Hi,
 
  I need some help with query string. Basically what I am doing is I
am
  sorting my table, much like you sort columns in OUTLOOK EXPRESS for
  instance with a little arrow...
 
 

http://www.kulchitski.com/btl/btl.php?lang=engpage=talkroom_showsort=s
  ex
 
  So all I need a function that will grab this query and will change
 sort=
  and another new variable (desc/asc) and will return the same string
 but
  with new values for certain variables... I ran across some function
 like
  this before when Ididn't need it, but just now when I need it badly
-
  can't seem to be able to find it. Hope someone out there can help.
 
  Thank you much.
  Vlad
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php