assume that there is an item count table and use an item table
when I want to make an item list
I want to show an item table
the behavior of an item table
is to add this item to the goods store
but I am shopping. How can I show it?
I think of several methods
the first one is to enter the name of the item immediately after joining to the property list
, and then use the ID to purchase his product
, but in this way, if the information of the product is changed, all the merchandise will have to change it
the second way is to enter only the value
one is the ID, of the goods and the other is the ID
of the goods, but the ID of the goods includes the product name
, so how do I display the goods? The only data I can catch is ID, using ID
how can I turn off another table?
grab the merchandise table according to the commodity ID, and then display the commodity information?
in this way, there will be no source to modify the update of product information
but I don"t know how to show this method?
user has id
user_cart has prod_id, id
product has prod_id, name, icon
my mysql query is
SELECT b.icon, b.name FROM user_cart as c
LEFT JOIN product AS b ON c.prod_id = b.id
Where c.user_id= "{$_SESSION["user-id"]}"
or
SELECT b.* FROM product as b
LEFT JOIN user_cart as c ON c.prod_id = b.prod_id
LEFT JOIN user AS a ON a.id = c.id
WHERE c.id = "{$_SESSION["user-id"]}"
pretend to be mysql structure
user_cart
user
product
the agent we show is:
<? while($row = mysqli_fetch_array($data)){?>
<?=$row["name"];?>
<?}?>
is there any trouble?