datadoit.com
|
| Posted: 08/24/2007, 7:12 PM |
|
Is there a quick and easy way to NOT send blank URL parameters from a
search screen?
|
|
|
 |
wkempees
Posts: 1679
|
| Posted: 08/25/2007, 2:25 AM |
|
Blank URL as in no search parameters entered?
Do validate on search button.
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
datadoit.com
|
| Posted: 08/25/2007, 7:10 AM |
|
Almost. If I have a search form with 20 fields on it to search, and the
user only searches one of the fields, the form post includes ALL of the
search fields.
mypage.php?s_field1=mike&s_field2=&s_field3=&s_field4=&s_field5= etc,etc.
Creates a whole lotta URL clutter on detailed search forms. I know I
can do a buncha custom programming on the receiving page to clean this
stuff out, but it is a lot of work. Looking or hoping for some simple
on/off type of action - if a value, post it, if not, don't post it.
Something that can be set project-wide would be awesome (like in
Common.php), or even a setting in Apache.
|
|
|
 |
DonB
|
| Posted: 08/25/2007, 7:48 AM |
|
The simplest approach I can think of is:
$_POST = array_diff( array_unique($_POST),array(""));
would reduce the array, basically taking out all the "duplicate' empty
elements, and then taking 'difference' of that result vs. an empty array
which will remove the remaining empty element.
This removes ALL duplicates (POST array elements with no value assigned to
them. Consider whether that's OK in your application. Probably is, just be
aware.
You could put this into Common.php or in specific pages, depending on how
broadly you want the effect to be felt.
--
DonB
http://ccswiki.gotodon.net
"datadoit.com" <datadoit@forum.codecharge> wrote in message
news:fapd80$52t$1@news.codecharge.com...
> Almost. If I have a search form with 20 fields on it to search, and the
> user only searches one of the fields, the form post includes ALL of the
> search fields.
>
> mypage.php?s_field1=mike&s_field2=&s_field3=&s_field4=&s_field5= etc,etc.
>
> Creates a whole lotta URL clutter on detailed search forms. I know I
> can do a buncha custom programming on the receiving page to clean this
> stuff out, but it is a lot of work. Looking or hoping for some simple
> on/off type of action - if a value, post it, if not, don't post it.
> Something that can be set project-wide would be awesome (like in
> Common.php), or even a setting in Apache.
>
|
|
|
 |
datadoit.com
|
| Posted: 08/25/2007, 2:21 PM |
|
DonB wrote:
> The simplest approach I can think of is:
>
> $_POST = array_diff( array_unique($_POST),array(""));
>
> would reduce the array, basically taking out all the "duplicate' empty
> elements, and then taking 'difference' of that result vs. an empty array
> which will remove the remaining empty element.
>
> This removes ALL duplicates (POST array elements with no value assigned to
> them. Consider whether that's OK in your application. Probably is, just be
> aware.
>
> You could put this into Common.php or in specific pages, depending on how
> broadly you want the effect to be felt.
>
--------------------------------
DonB = One Smart Feller!
I put this into my search form's OnValidate Event. An unexpected
benefit: It 'appears' to have drastically sped up the return results.
|
|
|
 |
DonB
|
| Posted: 08/27/2007, 8:15 AM |
|
I don't think that would have much effect on performance, other than the
initial 'build select'. The blank parameters shouldn't have been
participating in the query. It would be interesting to know if the speed
difference is perception or reality.
--
DonB
http://ccswiki.gotodon.net
"datadoit.com" <datadoit@forum.codecharge> wrote in message
news:faq6g9$tef$1@news.codecharge.com...
> DonB wrote:
> > The simplest approach I can think of is:
> >
> > $_POST = array_diff( array_unique($_POST),array(""));
> >
> > would reduce the array, basically taking out all the "duplicate' empty
> > elements, and then taking 'difference' of that result vs. an empty array
> > which will remove the remaining empty element.
> >
> > This removes ALL duplicates (POST array elements with no value assigned
to
> > them. Consider whether that's OK in your application. Probably is,
just be
> > aware.
> >
> > You could put this into Common.php or in specific pages, depending on
how
> > broadly you want the effect to be felt.
> >
> --------------------------------
>
> DonB = One Smart Feller!
>
> I put this into my search form's OnValidate Event. An unexpected
> benefit: It 'appears' to have drastically sped up the return results.
|
|
|
 |
|