Hi Guys,
Have a multiple select box. I'm trying to group columns and display
records under their paired groupings.
Code:
echo "<select name=\"patternThreads[]\" size=\"10\" multiple
style=\"font-family:monospace;\">\n";
$query = "select t.manufacturer, t.id, t.colour, t.colourID, t.type,
p.thread_index FROM kcs_threads t LEFT JOIN kcs_patternthreads p ON t.id
= p.thread_index WHERE p.pattern_index = '$id' OR p.pattern_index IS
NULL ORDER BY t.manufacturer, t.type";
$thread_manufacturer = '';
$thread_types = '';
$result = db_query($query);
while($thread = db_fetch($result)) {
if($thread_manufacturer !=
$thread['manufacturer']) {
echo "<option value=\"\"
class=\"adminEditLink\">{$thread['manufacturer']}</option>\n";
$thread_manufacturer =
$thread['manufacturer'];
}
if($thread_types != $thread['type']) {
echo "<option value=\"\"
class=\"adminEditLink\">{$thread['type']}</option>\n";
$thread_types =
$thread['type'];
}
}
echo "</select>\n";
The above does work.. but it displays the results like:
Manufacturer
Type
Manufacturer
Type
Manufacturer
Type
Etc..
What I'd like is to display them like:
Manufactuer - Type
Manufacturer - Type
Manufacturer - Type
I tried this code but only seems to group one TYPE and move onto the
next manufacturer and group that type.:
echo "<select name=\"patternThreads[]\" size=\"10\" multiple
style=\"font-family:monospace;\">\n";
$query = "select t.manufacturer, t.id, t.colour, t.colourID, t.type,
p.thread_index FROM kcs_threads t LEFT JOIN kcs_patternthreads p ON t.id
= p.thread_index WHERE p.pattern_index = '$id' OR p.pattern_index IS
NULL ORDER BY t.manufacturer, t.type";
$thread_manufacturer = '';
$thread_types = '';
$result = db_query($query);
while($thread = db_fetch($result)) {
if($thread_manufacturer !=
$thread['manufacturer']) {
echo "<option value=\"\"
class=\"adminEditLink\">{$thread['manufacturer']}";
$thread_manufacturer =
$thread['manufacturer'];
}
if($thread_types != $thread['type']) {
echo " -
{$thread['type']}";
$thread_types =
$thread['type'];
}
echo "</option>\n";
}
echo "</select>\n";
Any idea's where I am going wrong?
Thanks!!!
Aaron