私はmysqlクエリを実行し、回答の結果を特定のカテゴリ に保存しようとしていますが、最後の行の正確性が失われています。特定のカテゴリへのクエリの制限
$category_in_now = get_products_category_id($_GET['products_id']);
$similar_products = "SELECT p.products_type, p.products_id, pd.products_name,
p.products_image, p.products_price, p.products_tax_class_id,
p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity,
p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m
ON (p.manufacturers_id = m.manufacturers_id), " .
TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND p.master_categories_id == " . $category_in_now;
12月29日: 私はこれをやってしまったが、RANDのLIMIT部分にいくつかの質問にループの必要性が残っています、私はこれを正しくやっていますか?
<?php
echo '<div>';
$category_in_now = zen_get_products_category_id($_GET['products_id']);
for($i=0;$i<4;$i++) {
$products_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m
ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND p.master_categories_id = :catInNow ORDER BY rand() LIMIT 0,4";
$products_query_raw = $db->bindVars($products_query_raw, ':catInNow', $category_in_now, 'integer');
$result = $db->Execute($products_query_raw);
echo '<li>';
echo '<div id="item">';
if ($result->RecordCount() > 0) {
echo '<a href="' . zen_href_link('product_info', 'cPath=' . $cPath . '&products_id=' . $result->fields['products_id']) . '">';
echo zen_image(DIR_WS_IMAGES . $result->fields['products_image'], $result->fields['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
echo '</a>';
echo '</div>';
echo '</li>';
}
}
echo '</div>';
?>
あなたの質問は何ですか?意図した通りに動かないのですか? –
[コードブロックのフォーマット方法](http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks) – ajreal