searls03 Posted June 18, 2012 Share Posted June 18, 2012 I am not very knowledgeable on join queries but this is what i have: $sql=mysql_query("select cat.id, cat.subcategory, cat.category, prod.product, prod.price, prod.id, prod.category, prod.subcategory from categories cat left join products prod on cat.category = prod.category where prod.prodcut='$prodcut' and prod.category='$category' "); What I need is for a query to run through the database table"categories" picking out all the categories, then based on the category, it picks from "products" with the same category in the column "category". here is the problem though, I need all the results to display, so there are like 10 categories, I need to see all those categories, then there are multiple products for each category, and I would like all those to display. anyhelp here? Am i even remotely close? Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/ Share on other sites More sharing options...
searls03 Posted June 18, 2012 Author Share Posted June 18, 2012 I would like to do this using a PHP query, not a mysql sql query Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1354841 Share on other sites More sharing options...
Pikachu2000 Posted June 18, 2012 Share Posted June 18, 2012 What exactly is a "php query"? Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1354842 Share on other sites More sharing options...
searls03 Posted June 18, 2012 Author Share Posted June 18, 2012 I am saying that I would like to use PHP to query the database, I don't want to do it from PHPmyAdmin/Mysql. so a query like this: // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM cart where cart_id = '".$_SESSION['cart_id']."' && academy= '$academy' && product123 !=''"); while($row = mysql_fetch_array($sql)){ $product = $row["product123"]; $price1 = $row["price"]; $id = $row["product_id"]; $qty = $row["quantity"]; Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1354844 Share on other sites More sharing options...
Philip Posted June 18, 2012 Share Posted June 18, 2012 It is considered a MySQL question because you are connecting and querying a MySQL database - even if it is via PHP Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1354849 Share on other sites More sharing options...
searls03 Posted June 18, 2012 Author Share Posted June 18, 2012 ok, thanks, do you have any advice? Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1354850 Share on other sites More sharing options...
fenway Posted June 30, 2012 Share Posted June 30, 2012 What was wrong with your original query? Quote Link to comment https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1358157 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.