在庫表

$row){ if(isset($_SESSION['sales'])){ if(array_key_exists($row['pid'],$_SESSION['sales'])){ ++$_SESSION['sales'][$row['pid']]; }else{ $_SESSION['sales'] += array($row['pid'] => 1); } }else{ $_SESSION['sales'] = array($row['pid'] => 1); } } $sql='select * from product order by pstock'; $result = php_query($sql); echo "" . ''; echo ""; foreach($result as $record => $row){ $c_stock = $row['pstock']; if(isset($_SESSION['sales'])){ if(array_key_exists($row['pid'],$_SESSION['sales'])){ $c_stock = $row['pstock']-$_SESSION['sales'][$row['pid']]; }else{ $c_stock = $row['pstock']; } } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
商品コード商品名メーカー価格在庫
" . $row['pid'] . "" . $row['pname'] . "" . $row['pmaker'] . "" . $row['pprice'] . "円" . "" . $c_stock. "個" . "
" . ""; unset($_SESSION['sales']); ?>