我想用php做一个购物车。我想发送id到下面的文件中的php代码。我试图用php_self来做到这一点。我得到这些错误。如何通过超链接发送数据到php文件本身
*Undefined index: movie_id in C:\xampp\htdocs\ITA_WEBSITE\shopping_cart.php on line 60
*mysqli_fetch_object() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\ITA_WEBSITE\shopping_cart.php on line 61
*Undefined index: cart in C:\xampp\htdocs\ITA_WEBSITE\shopping_cart.php on line 84
下面的代码
session_start();
include('dbconfig.php');
$result = mysqli_query($con,"SELECT * FROM movie_details");
?>
Movie Storeimage_path;?> alt=<?php echo $product->image_path;?>>
include('dbconfig.php');
include('movie_products.php');
$result = mysqli_query($con, 'SELECT * FROM movie_details WHERE movie_id = '.$_GET['movie_id']);
$product = mysqli_fetch_object($result);
if(isset($_GET['movie_id'])){
$item = new Item();
$item->movie_id = $product->movie_id;
$item->movie_title = $product->movie_title;
$item->price = $product->price;
$item->quantity = 1;
$_SESSION['shopping_cart'][] = $item;
}
?>
Cart
Movie Title | Price | Action |
---|
$cart = unserialize(serialize($_SESSION['cart']));
for($i=0; $i
?>
<?php echo $cart[$i]->movie_title;?><?php echo $cart[$i]->price;?>movie_products.php文件
class Item{
var $movie_id;
var $movie_title;
var $price;
var $quantity;
}
?>
注:我试图通过以下的教程 需要一些帮助来做到这一点!
2016-09-17
Kasun