----- Original Message -----
From: "Rich Cavanaugh" <[EMAIL PROTECTED]>
To: "Dave Mariner" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 2001 1:53 AM
Subject: RE: [PHP] [OT-ish] Optional Extras.


> Dave,
> I did something similar and I came up with an interesting way of
> approaching it:
>
> Assign IDs to each car (obviously).
> Assign an ID to each option.
> Match up your car IDs and option IDs in a seperate table.
>
> Here's some table defs:
>
> create table cars (
> carid int auto_increment,
> name varchar(255)
> );
>
> create table options (
> optid int auto_increment,
> name varchar(255)
> );
>
> create table caroptions (
> carid int,
> optid int
> );
>
> (if my sql is off, don't flame me, you at least get the idea)
>
> Here's the search:
>
> $words should be a comma delimited list if the options the user chose.
>
> select count(o.carid) as cnt, o.carid as id, c.name from caroptions as o,
> cars as c where and o.optid in ({$words}) and o.carid = c.carid group by
> o.carid, c.name order by cnt DESC
>
> This would give you a list of cars ordered by the best match to worst
match.
>
Bingo!! Looks about right. What I was missing was the "IN" and a cdl of the
options. If it works (as it looks like it should), pop into Paphos & I'll
buy you that pint!!


Cheers,

Dave




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