php類
已實現通過讀取txt文檔進行產品展示,如何跟據不同產品種類分類添加產品介紹?
plantslist.txt:
$plantsclassify=array("產品種類","產品種類","產品種類");
$產品種類=array(array("產品名稱","介紹",價格),array("名稱","介紹",價格),array("名稱","介紹",價格));
$產品種類=array(array("產品名稱","介紹",價格),array("名稱","介紹",價格),array("名稱","介紹",價格));
$產品種類=array(array("產品名稱","介紹",價格),array("名稱","介紹",價格),array("名稱","介紹",價格));
?>
include("plantslist.txt");
foreach($plantsclassify as $classify)
{
echo "$classify ";
}
echo "查看購物車";
if(isset($_GET["catalog"]))
{
$catalog=$_GET["catalog"];
$_SESSION["catalog"]=$catalog;
echo "
";
echo "
"; echo "
"; echo "
植物名 | "; echo "
詳細資料 | "; echo "
價格 | "; echo "
購買 | "; echo "
"; foreach($$catalog as $plants) { echo "
"; foreach ($plants as $val) { echo "
$val | "; } echo "
| "; echo "
"; } echo "
"; echo "
| "; echo "
"; echo "
";
echo "";
}
if(isset($_GET["success"]))
{
if($_GET["success"]==0)
{
echo "alert('請選購植物')";
}
if($_GET["success"]==1)
{
echo "alert('已加入購物車!')";
}
}
?>