我需要产品清单,从女巫我可以随机显示4个项目。
我曾尝试编写PHP代码,但需要帮助完成语法和变量。
<?php
// my product list
function productlistX {
$array = array(
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
$product {$name = 'product name', $link = 'product link', $img = "product image"};
)
// need to display 4 random products from the array above
foreach {
echo "<li>".$name . $link . $img . "</li>"
}
}
// display these random products in my ajax tab (products.php?order=mytab)
$data['mytab'] = $productlistX;
if (isset($data[$_GET['order']])) {
echo $data[$_GET['order']];
}
?>
提前感谢!