On Sun, 21 Nov 2010 11:19:04 -0700
"Ben Miller" <biprel...@gmail.com> wrote:

> 
> To help clarify - the 3 tables look something like the following (tableName
> => column,column,column...):
> 
> Products => product_id,product_name,product_description...  (key =
> product_id)
> Criteria => criteria_id,criteria_title,criteria_text,...  (key =
> criteria_id)
> Criteria_values => product_id,criteria_id,criteria_value,... (key =
> product_id & criteria_id)
> 
> The user selects up to X product_id's to compare, stored in
> $selected_products.
> 
> I then need to get each criteria_title and criteria_text from
> table(criteria) where there is a matching criteria_id in
> table(criteria_values) for each/all $selected_products, also returning the
> criteria_value for each $selected_products, ultimately ending up with an
> array or object that looks something like:
> 
> (Assuming the user selected Product A (product_id=1), Product B
> (product_id=2) and Product C (product_id=3)
> 
> criteria => Array  (
>       [$criteria_id] => Array (
>               [title] => query_row[criteria_title]
>               [text] => query_row[criteria_text]
>               [values] => Array (
>                       [1] => Product A's value for this criteria
>                       [2] => Product B's value for this criteria
>                       [3] => Product C's value for this criteria
>               )
>       )
>       [$criteria_id] => Array (
>               .....
>       )
> )
> 
> Again, displaying only/all criteria where there is a matching value for
> each/all $selected_products
> 
> Thanks again,
> Ben
> 
> 

You should probably select all relevant rows for each product, without checking 
that a given criteria has a matching value for each product. Use php to filter 
out the criteria which do not apply to all products.

-- 
Simcha Younger <sim...@syounger.com>

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

Reply via email to