Re: query, display and grouping.. one way works but notanother

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

 



Aaron Wolski wrote:

Hi Guys,
Have a multiple select box. I'm trying to group columns and display
records under their paired groupings.
[snip]
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?

Wouldn't it just be:


while($thread = db_fetch($result)) {
{
echo "<option value=\"\" class=\"adminEditLink\">{$thread['manufacturer']} - {$thread['type']}</option>\n";
}


Although I don't see where you're setting a value for the <option> in your code.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--
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