
July 30th, 2003, 12:32 PM
|
|
Junior Member
|
|
Join Date: Jul 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
looping problem
Hi All,
New to this board. Hope to contribute and receive as much as possible.
Here's a current problem Im having.
Code:
PHP Code:
<?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
}
?>
The above code is producing results like (assuming A-D was selected):
PHP Code:
A-D Designers
D-G Designers
G-J Designers
J-M Designers
M-P Designers
P-S Designers
S-V Designers
V-Y Designers
Y-Z Designers
Artists Collection The
Barrick Samplers
Bent Creek
Brown House Studio
Butternut Road
Calico Crossroads
Canterbury
Cross My Heart
Crossed Wing Collection
What I need it to do is (again assuming A-D was selected):
PHP Code:
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 Designers
G-J Designers
J-M Designers
M-P Designers
P-S Designers
S-V Designers
V-Y Designers
Y-Z Designers
Or if D-G was selected:
PHP Code:
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 Designers
J-M Designers
M-P Designers
P-S Designers
S-V Designers
V-Y Designers
Y-Z Designers
I've tried a few placements of the foreach loop but nothing seems to work. Anyone have an idea?
Thanks!
Aaron
|