mysql - php function with with multiple queries - inner join duplicating results? -


i have been tackling trying incorporate , implement shopping cart system.

how make display 1 add cart button each shop product listing correct price showing?

i have function in functions file. , function has 2 queries in it.

first table called: products

    $results = $db->query("select distinct * `products` inner join `shop` on `products`.`id` = `shop`.`id`;");     $paypalcontent = "";     while($row = $results->fetch_assoc())         { 

second table called: shop

    $results = $db->query("select distinct * shop ");     while($row = $results->fetch_assoc())     { 

i use

unset($results); unset($row); 

to unset results second query can queried.

so results resulting in repeating add cart buttons rows in products table. show picture.

enter image description here

so table info: shop table has info in it, 18 rows pictures , links , descriptions etc etc.

structure:

 table 1 - products: id, name, image, price, status   table 2 - shop: id,title, name, standardprice, commercialprice, image, image2, image3, image4, image5, image6, description, descr, more, moredetails, url, paypalstandard, paypalcommercial 

i removing paypalstandard , paypalcommercial once got working. standardprice , commercial price other pages.

second table products creates buttons paypal end in form.

so have row standard , commercial in each table, products , shop. need display correct add cart button each shop listing - 1 button each listing. needing linked product creates correct button , price each shop product.

edit: need show 1 button per shop item. see in picture above shows 4 buttons. need show 1 each correct price reflected in each product.

further edit: 2 tables both have id , both primary keys. have tried many different queries left , right join no avail.

thanks

well first start i'd recommend use js making temporary cart front end. after build data , send int json or whatever , update using needed items, dont reserve or inner because not needed. wait xhr or whatever php post data , update data dont use inner because not needed @ all.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -