On Tue,  4 Dec 2001 11:46, René Fournier wrote:
> From: René Fournier <[EMAIL PROTECTED]>
> Date: Mon Dec 03, 2001  06:11:23  PM US/Mountain
> To: Benjamin Pflugmann <[EMAIL PROTECTED]>
> Cc: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Subject: Re: MySQL ORDER BY or PHP Sort? Oops.
>
> Here is the snippet of code that is presenting a challenge:
>
> ---------------------------------------------------
> <?php
>
> // FETCH MODELS TECH SPECS
>
> function models ($lang,$db) {
>       $modelsheader = mysql_fetch_array(mysql_query("SELECT * FROM models
> WHERE lang='$lang' AND key1='header'",$db));
>       $result = mysql_query("SELECT * FROM models WHERE key1='data' ORDER
> BY price ASC",$db);
>       mysql_close();
>       include ('../common/models.inc');
> }
>
> models($lang,$db);
>
> // CREATE A MULTI-DIMENSIONAL MODELS ARRAYS BASED ON THE NUMBER OF
> MODEL ROWS IN THE TABLE
>
> $i = 0;
> do {
> $allmodels[$i] = $models;
> $i++;
> } while ($models = mysql_fetch_array($result));
>
> // NUMBER OF MODELS
>
> $first = 1;
> $last = sizeof($allmodels)-1;
> $colspan = ($last * 2)+1;
>
> ?>
> ---------------------------------------------------
> The problem is, if I sort by the price field, the ordering of the
> series gets mixed up (since low-end models in higher-end series cost
> more than some higher-end models in lower-end series (confused?? I am
> :-)  If I just sort by series, I don't get the prices in order within
> each series (big problem). And if I sort by BOTH series and price,
> which is the logical thing to do, and which many people have kindly
> suggested (and which I have tried), well, it doesn't work, because the
> series must be sorted in a non-alphabetical way.

If you make the series field an enum type, it will sort in the order in 
which the values are inserted

Put them in the order Baby>Genesis>Super>Predator>Millennium and that's 
how they'll come out.

-- 
David Robley      Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES      Flinders University, SOUTH AUSTRALIA  

   We now return you to your regularly scheduled flame-throwing

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to