$product_data = $mysqli->query(
"SELECT
p.url as url,
p.description as description,
p.info as info,
p.note as note,
p.content as content,
p.name as pname,
p.icon as icon,
p.price as price,
p.original_price as original_price,
p.prod_id as prod_id,
p.stock as stock,
p.views as views,
s.name as sname,
c.name as cname,
p.add_time as add_time
FROM `product` as p
JOIN
`store` as s ON p.store_id = s.store_id
JOIN
`category` as c ON c.category_id = p.category_id
WHERE
p.active = 1
ORDER BY `prod_id` DESC
while($row = mysqli_fetch_array($product_data)){
$theme = $mysqli->query(
"SELECT
t.name as tname
FROM `product` as p
JOIN
`product_theme` as pt ON p.prod_id = pt.prod_id
JOIN
`theme` as t ON t.theme_id = pt.theme_id
WHERE
p.prod_id = "{$row["prod_id"]}" "
);
$buyTotal = mysqli_fetch_array($mysqli->query(
"SELECT sum(quan) as quan FROM `stock`
WHERE
`prod_id` = "{$row["prod_id"]}" "
));
$viewsIp = mysqli_num_rows($mysqli->query(
"SELECT * FROM `product_view`
WHERE
`prod_id` = "{$row["prod_id"]}" "
));
$pre = mysqli_num_rows($mysqli->query(
"SELECT sum(quan) as quan FROM `user_pre`
WHERE
`prod_id` = "{$row["prod_id"]}" "
));
}
Let"s take a look at my dilemma
while four queries all need $product_data
$row ["prod_id"]
, and then these four queries will have other different functions
, such as showing that the conditions are available, printing the sum of a certain position
<?=$pre;?>
<?=$buyTotal["quan"];?>
is done in this way.
but I hope that God can teach me, "I am civilized and grateful."