RE: alphabetical sorting... limiting and paginating onnext set of letter group

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

 



Sorry all but getting kinda desparate here :(

Trying a few different things and still nothing seems to work.

Does anyone have a kick in the right direction that I could explore
here?

Sorry for the repost.

Thanks

Aaron

-----Original Message-----
From: Aaron Wolski [mailto:aaronjw@martekbiz.com] 
Sent: July 30, 2003 9:47 AM
To: 'ramil@astra.ph'; 'php-db@lists.php.net'
Subject: RE:  alphabetical sorting... limiting and paginating
onnext set of letter group

Alrighty..

Working with your code and some others I've come up with this:

<?php
if ($sort) {

	$list = explode("-", $sort);

}

$test = Array('A-D', 'D-G', 'G-J', 'J-M', 'M-P', 'P-S', 'S-V', 'V-Y',
'Y-Z');

foreach ($test as $group) {
	if (strtolower ($group) != $sort) {
		$lgroup = strtolower ($group);
		echo "<a
href=\"patterns.php?sort={$lgroup}\">{$group}</a><br />";
	}
}


$designerQuery = db_query("SELECT designer FROM kcs_patterns WHERE
designer BETWEEN '".$list[0]."' and '".$list[1]."' GROUP BY designer
ORDER BY designer");
while ($designerResult = db_fetch($designerQuery)) {

?>
<img src="Graphics/spacer.gif" width="10" height="1"><a href=""><font
class="catalogueSubCatLink"><?php echo $designerResult['designer']; ?>
Designers</font></a><br>
<?php

	}	

?>

This works as I need it to.. shifting from one set of results to
another. My problem is how do I format it like the following(assuming
A-D was selected):

A-D Designers

Artists Collection The
Barrick Samplers
Bent Creek
Brown House Studio
Butternut Road
Calico Crossroads
Canterbury
Cross My Heart
Crossed Wing Collection

D-G
G-J
J-M
M-P
P-S
S-V
V-Y
Y-Z

Or if D-G was selected:

A-D

D-G Designers

Datta Bonnie
Design Connection
Design Connection The
DMC
Donna Gallagher Creative Needlearts
Dragon Dreams
Family Tree The
Fanci That
Full Circle Designs

G-J
J-M
M-P
P-S
S-V
V-Y
Y-Z

I've tried a few placements of the foreach loop but nothing seems to
work. Any ideas?

Thanks!



-----Original Message-----
From: Ramil G. Sagum [mailto:ramil@astra.ph] 
Sent: July 29, 2003 11:38 PM
To: php-db@lists.php.net
Cc: Aaron Wolski
Subject: RE:  alphabetical sorting... limiting and paginating
onnext 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