Jump to content

join queries


searls03

Recommended Posts

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?

Link to comment
Share on other sites

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"];

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.