Я пытался отправить информацию из формы в мой массив, чтобы он мог хранить эту информацию и отображать ее, когда это необходимо.Я уже успел отправить данные с одной страницы и отобразить их на другой, но я хочу, чтобы они были сохранены в массиве и отображали сразу несколько проблем.Мне сказали использовать этот стиль массива для выполнения работы другом (см. Мой код массива ниже, чтобы понять), но он дает мне синтаксическую ошибку, я пробовал разные типы массивов, но я всегда получаю синтаксическую ошибку.
Код моей корзины (содержит мой массив)
<?php
session_start();
?>
<?php
require_once("head.php");
?>
<?php
require_once("nav.php");
?>
<link id='stylecss' type="text/css" rel="stylesheet" href="css/cartstyle.css">
<link id='stylecss' type="text/css" rel="stylesheet" href="css/style.css">
<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="utf-8">
<title> Shopping Cart </title>
<div class="shopping-cart">
<!-- Title -->
<div class="title">
Shopping Cart
</div>
<?php
if(!isset($_SESSION['Array'])) {
(
Array
(
[got] => Array
(
[id] => MO1
[option]
[qty]
[price]
)
[friends] => Array
(
[id] => MO2
[option]
[qty]
[price]
)
[inception] => Array
(
[id] => MO3
[option]
[qty]
[price]
)
)
)
}
?>
<?php
var_dump ($_POST);
echo $_POST['option'];
echo $_POST['id'];
echo 'x';
echo $_POST['qty'];
?>
<script>
$('.like-btn').on('click', function() {
$(this).toggleClass('is-active');
});
</script>
<script>
$('.minus-btn').on('click', function(e) {
e.preventDefault();
var $this = $(this);
var $input = $this.closest('div').find('input');
var value = parseInt($input.val());
if (value &gt; 1) {
value = value - 1;
} else {
value = 0;
}
$input.val(value);
});
$('.plus-btn').on('click', function(e) {
e.preventDefault();
var $this = $(this);
var $input = $this.closest('div').find('input');
var value = parseInt($input.val());
if (value &lt; 100) {
value = value + 1;
} else {
value =100;
}
$input.val(value);
});
</script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
<?php
require_once("footer.php");
?>
и код моего продукта (моя форма здесь):
<div class="color">
<?php
session_start();
?>
<!-- Keep wireframe.css for debugging, add your css to style.css -->
<link id='wireframecss' type="text/css" rel="stylesheet" href="../wireframe.css" disabled>
<link id='stylecss' type="text/css" rel="stylesheet" href="css/style.css">
<script src='../wireframe.js'></script>
<?php
$title = "WatchFlix";
$style="css/style.css";
/*include is a php fuction which place all codes(php, html) at the location where the include statement is placed.*/
?>
<?php
include("head.php")
?>
<?php
include("nav.php")
?>
<?php
$movie = array("got"=>"Game of Thrones: Season 1", "frd"=>"Friends: Season 1", "incp"=>"Inception");
?>
<main class="row">
<div class="column">
<img class="moviephoto" src="gotimage.jpg" alt="friends"/> <br>
<div class="bmove">
<form action="cart.php" method="post">
Game of thrones season 1
<input type = "hidden" name = "id" value = "M01" />
<br>
<select name="option">
<option value="HD">HD</option>
<option value="Full HD">Full HD</option>
<option value="Blu-ray">Blu-ray</option>
</select>
<div class="widthc">
<button class="prod" id="minus">−</button>
<input type="number" name="qty" value="0" id="qty" min="0" max="15"/>
<button class="prod" id="plus">+</button>
<br><br>
<button class="prod" type="submit"> Submit</button>
</form>
</div>
</div>
</div>
<div class="column">
<h2 class="movieheading"> Game of Thrones </h2>
<div class="rating">
<h4> Rating: <span style ="font-weight:normal;">MA 15+</span></h4>
</div>
<br>
<div class="release">
<h4> Release Date: <span style ="font-weight:normal;">17 April 2011</span> </h4>
</div>
<br>
<div class="cast">
<h4> Cast: <span style ="font-weight:normal;">Peter Dinklage, Lena Headey, Emilia Clarke, Kit Harington, Sophie Turner, Maisie Williams</span></h4>
</div>
<br>
<div class="category">
<h4> Category: <span style ="font-weight:normal;"> Action/Adventure/Drama/Fantasy/Romance </span> </h4>
</div>
<br>
<div class="moviedetail">
<h4>T.V Show Details:</h4>
<p>Years after a rebellion spurred by a stolen bride to be and the blind ambitions of a mad king, Robert of the house Baratheon sits on
the much desired Iron Throne. In the mythical land of Westeros, nine noble families fight for every inch of control and every drop
of power. The King's Hand, Jon Arryn, is dead. And Robert seeks out his only other ally in all of Westeros, his childhood friend
Eddard Stark. The solemn and honorable Warden of the North is tasked to depart his frozen sanctuary and join the King in the
capital of King's Landing to help the now overweight and drunk Robert rule. However, a letter in the dead of night informs Ned
that the former Hand was murdered, and that Robert will be next. So noble Ned goes against his better desires in an attempt to
save his friend and the kingdoms. But political intrigue, plots, murders, and sexual desires lead to a secret that could tear the
Seven Kingdoms apart. And soon Eddard will find out what happens when you play the Game of Thrones.</p>
</div>
<div class="column">
</div>
<br><br><br>
</main>
<script>
const minusButton = document.getElementById('minus');
const plusButton = document.getElementById('plus');
const inputField = document.getElementById('qty');
var currentValue = 0;
minusButton.addEventListener('click', event => {
event.preventDefault();
currentValue = Number(inputField.value) >> 0;
currentValue = currentValue - 1;
if (currentValue < inputField.min) {
inputField.value = inputField.min;
} else {
inputField.value = currentValue;
}
});
plusButton.addEventListener('click', event => {
event.preventDefault();
currentValue = Number(inputField.value) >> 0;
currentValue = currentValue + 1;
if (currentValue > inputField.max) {
inputField.value = inputField.max;
} else {
inputField.value = currentValue;
}
});
</script>
<br><br><br>
<?php
include("footer.php")
?>
</div>