Well I'm not good enough at SQL to do this, but how about you get PHP to
figure out all the combinations, ie
1, 3, 5, 2, 6, 5&2, 3&2, 3&2&1, 5&1, 6&1, 2&1, 3&1

Then do a set of
SELECT * FROM table WHERE number=1
SELECT * FROM table WHERE number=3
....
SELECT * FROM table WHERE number=3 OR number=1

Then you can read all these values into a array of some kind and do what you
want...

I think I may mis-understood the problem a little, but I hope this helps

Andrew

----- Original Message -----
From: "mikeyb" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 30, 2002 10:26 PM
Subject: [PHP] [more info] Finding all instances


>
> Hi,
>
> I have a little problem I am trying to solve but right now I have no idea
> where to begin.  I am preying that someone out there might be able to help
> me.
>
> In my MySQL database I have a group of figures, one for each record.
> Through PHP I have concluded at a 'magical' number which I will need to
> compare against.  What I need to do is try to find all instances or
> combinations of figures from the database which fit inside this magical
> figure, but how I do this I am not sure.  I'm thinking I need to somehow
> read the figures into an array somehow but I have not had enough
experience
> with php to know how to even do this effectively.  I have read up on the
> issue but it all seems double dutch, and I don't know what I need to do
from
> this point anyway.
>
> For example:
>
> Magic Number: 7
> Numbers in database: 12, 6, 2, 8, 5, 3, 1
>
> Combinations returned: 1, 3, 5, 2, 6, 5&2, 3&2, 3&2&1, 5&1, 6&1, 2&1, 3&1
>
> Can anyone please help?
>
> [MORE INFO: Each record in the database has a unique identifier, numberid,
> which would be used to identify which records are used in the
combinations.
> We can assume for now that the numberid is equal to the number in the
> database for simplicity sake.  Sorry for not making this clear the first
> time]
>
> Thanks,
> Michael.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to