1
を使用するには、誰かが私に言うことはできますか?
<?php
session_start();
$page = "index.php";
mysql_connect('localhost','root','') or die (mysql_error());
mysql_select_db('products') or die (mysql_error());
if(isset($_GET['add'])){
$_SESSION['cart_'.$_GET['add']]+='1';
}
else {
}
function products(){
$query = 'SELECT id,name,description,price FROM products WHERE quantity>0 ORDER BY id ASC';
$get = mysql_query($query);
if($get == 0){
echo "There are no products to display";
}
else{
while ($get_row = mysql_fetch_assoc($get)) {
echo '<p>'.$get_row['name'].'<br/>'.$get_row['description'].'<br/>'.$get_row['price'].'<a href="cart.php?add='.$get_row['id'].'">Add</a>'.'</p>';
}
}
}
?>
あなたのカートが確実にリクエスト間で永続化したいので? –
セッション変数は、セッションがアクティブになるたびに利用可能になります。セッション変数がある間は、 "通常の"変数はページを通して持続しません。 – Daan
ありがとうございますが、それを変数に格納することは可能ですか?それは間違いを起こさないだろうか? – isabel