Re: alphabetical sorting... limiting and paginatingonnext set of letter group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Where $string = 'A, D, P'

$fstring = str_replace(',',"','",$string);
$query = "SELECT * FROM Table WHERE LEFT(column,1) IN ('$fstring')";

Some validation would be in order, but that's the basic idea. Same idea for
the original question, only you control the value of $string.

---John Holmes...

----- Original Message ----- 
From: "Ow Mun Heng" <ow.mun.heng@wdc.com>
To: <ramil@astra.ph>; <php-db@lists.php.net>
Cc: "Aaron Wolski" <aaronjw@martekbiz.com>
Sent: Wednesday, July 30, 2003 6:53 AM
Subject: RE:  alphabetical sorting... limiting and paginatingonnext
set of letter group


Hi Ramil,

I'm also facing a similar problem, I would like to get the list
based on user Input.

Please input 1st Letter of designers wanted : A, D, P

I've tried using OR but it somehow screws things up.

Cheers,
Mun Heng, Ow
H/M Engineering
Western Digital M'sia
DID : 03-7870 5168


-----Original Message-----
From: Ramil G. Sagum [mailto:ramil@astra.ph]
Sent: Wednesday, July 30, 2003 11:38 AM
To: php-db@lists.php.net
Cc: Aaron Wolski
Subject: RE:  alphabetical sorting... limiting and
paginatingonnext set of letter group


On Wed, 2003-07-30 at 11:17, Aaron Wolski wrote:
> Hey,
>
> Thanks.
>
> Is there anyway this can be performed one function/loop?
>

yes of course. =) just create a function that takes in two letters as a
parameter,
then build the query string from it.


function($char_begin, $char_end)

{
  $q_begin = strtolower($char_begin);
  $q_end = chr(ord(strtolower($char_begin))+1);
  $query = "SELECT designer_name FROM designer WHERE designer_name BETWEEN
'".$q_begin."' AND '".$q_end."' ORDER BY designer_name";


  //do your query here.
}


> I knew it was possible with several queries.. I guess I was just looking
> for a all_in_one solution.
>
> Thanks for your help!

> Aaron
>
> -----Original Message-----
> From: Ramil G. Sagum [mailto:ramil@astra.ph]
> Sent: July 29, 2003 11:07 PM
> To: Aaron Wolski
> Subject: Re:  alphabetical sorting... limiting and paginating
> onnext set of letter group
>
> On Wed, 2003-07-30 at 10:36, Aaron Wolski wrote:
> > Hi Guys,
> > What I would like to do is:
> > Pattern Designers:
> >
> > A/B/C
> >
> > Artists Collection The
> > Barrick Samplers
> > Bent Creek
> > Bobbie G. Designs
> > Calico Crossroads
> > Charland Designs
> > Country Cross Stitch
>
> > Click for D/E/F
> > Click for G/H/I
> > Click for J/K/L
> >
> > When the user clicks on one of the another Letter Groupings... the
> > "A/B/C" changes to whatever they selected as does the displayed
> results
> > for their selection.
> >
> > Is this even possible?
> >
> > Aaron
>
> yes it is. =)
>
> try for a/b/c
>
> SELECT designer_name FROM designer WHERE designer_name BETWEEN 'a' AND
> 'd' ORDER BY designer_name;
>
> for d/e/f :
>
> SELECT designer_name FROM designer WHERE designer_name BETWEEN 'd' AND
> 'g' ORDER BY designer_name;
>
> for j/k/l:
>
> SELECT designer_name FROM designer WHERE designer_name BETWEEN 'j' AND
> 'm' ORDER BY designer_name;
>
>
>
> hope this helps.
>
>
> ramil



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


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux