brentman Posted May 20, 2014 Share Posted May 20, 2014 I have users in my database with many stored points ie age, gender, interests etc. about 20 points in all. I have a table of products that I want to recommend only applicable products. They each have saved like minage, maxage, gender, interest etc for the ideal consumer. ie dress gender=f This is the bare bones of what I have so far: $result = mysql_query("SELECT * FROM user_table WHERE hash='$session_id'"); $rowuser = mysql_fetch_array($result); $result = mysql_query("SELECT * FROM products"); $rowproducts = mysql_fetch_array($result); So now I have $rowuser['gender'] = m , how do I remove all from $rowproducts where gender = f? Is there a best way to do this knowing I have about 20 points to go through before I am left with an array with just the best selection of products for this user in it? Quote Link to comment Share on other sites More sharing options...
trq Posted May 20, 2014 Share Posted May 20, 2014 Sorry, but very little of that post makes sense. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted May 20, 2014 Share Posted May 20, 2014 Hi, and what exactly prevents you from using the WHERE clause or doing a join? Unless your rules are so complex that they exceed the capabilities of MySQL, this is simply a matter of writing one query: SELECT -- something useful, not just "*" FROM products JOIN users ON products.gender = users.gender AND ... WHERE users.id = 1 ; Quote Link to comment Share on other sites More sharing options...
brentman Posted May 20, 2014 Author Share Posted May 20, 2014 I have a person who is male, aged 30 and has kids. I have a list of products with information like (product should only be shown to people with kids or product should only be shown to men aged 30 or older) I have an array of the persons details and an array of all products with their details. How do I remove the products from the array that do not match the users details. ie remove dresses when the user is a male. Quote Link to comment Share on other sites More sharing options...
trq Posted May 20, 2014 Share Posted May 20, 2014 As Jacques1, you would be better doing this within your queries. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.