Re: [OT-ish] Optional Extras.
| From: | Dave Mariner | Date: | Tue, 26 Jun 2001 11:00:06 +0000 |
| Subject: | Re: [OT-ish] Optional Extras. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55230@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Rich Cavanaugh" <rcavanaugh@advolve.com>
To: "Dave Mariner" <dave@medlab-group.com>; <php-general@lists.php.net>
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