Re: query and display acting weird...
| From: | CPT John W. Holmes | Date: | Fri, 25 Jul 2003 19:05:28 +0000 |
| Subject: | Re: query and display acting weird... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29482@lists.php.net to get a copy of this message | ||
Probably need:
ORDER BY t.manufacturer, t.colourID
---John Holmes...
----- Original Message -----
From: "Aaron Wolski" <aaronjw@martekbiz.com>
To: <php-db@lists.php.net>
Sent: Friday, July 25, 2003 2:58 PM
Subject: [PHP-DB] query and display acting weird...
> Hi Guys,
>
> 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.colourID";
>
> $thread_manufacturer = '';
>
> $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'];
> }
> }
>
> echo "</select>\n";
>
> In my select box I am getting results like:
>
> Canterbury Cross Fabrics
> Zweigart
> Permin
> Zweigart
>
> I SHOULD be getting:
>
> Canterbury Cross Fabrics
> Zweigart
> Permin
>
>
> This was once working.. as it should have but today more data was dumped
> into the table which is causing the second Zweigart to be displayed.
>
> If I group the manufacturer in the query then I only one record
> displayed for the corresponding manufacturers.
>
> Any clue how I can make it so that everything is sorted under grouped
> manufacturers but still get ALL the results for the manufacturer at the
> same time?
>
> Have over 4000 records which was causing a LONG loading time in the
> browser so John Holmes gave me the above query to replace where I had 3
> queries doing the same thing.
>
>
> ANY thoughts would be greatly welcomed!
>
> Thanks
>
> Aaron
>