phtml 파일에는 price
, id
등을 포함한 모든 데이터베이스가 표시되며 php 파일 Details
에서 사용자가 집세를 누르려하면 해당 ID를 사용하여 add
메서드를 사용하여 상점에 저장합니다. 나는 사용자가 체크 아웃 할 때 그래서 사용자가 선택한 항목의 ID를 사용하여 모든 정보를 검색하는 것이다 데이터베이스에서 항목의 ID를 저장하는 이유는이 오류사용자가 선택한 항목의 ID를 가져 오는 중입니까?
Fatal error: Function name must be a string.
에게 그 이유를 점점 계속. 또한 배열 목록을 사용하여 더 많은 항목을 저장하는 중입니다. 항목의 ID를 얻는 방법은 추가 바구니 파일에 로컬 변수 $tem = $_POST(['$dvdDetails->getDvdId()']);
을 사용하는 것입니다.하지만 해당 값이 올바른 값인지 확인하지는 못합니다. foreach 루프가 있고 변수의 지속 시간이 메서드의 끝에서 왜곡되므로 항목의 ID를 어떻게 가져올 수 있습니까?
<?php
require_once('Models/Product.php');
class Shop {
private $_products = array();
public function getProducts()
{ return $this->_products;}
public function addProduct(Product $product)
{ $this->_products[] = $product;
return $this;
}
}
?>
<?php
class Option {
private $_optionKey;
private $_optionValue;
public function getKey()
{ return $this->_optionKey; }
public function getVlue()
{
return $this->_optionValue;
}
public function setOption($key, $value)
{
$this->_optionKey = $key;
$this->_optionValue = $value;
return $this;
}
}
?>
<?php
require_once('Models/Option.php');
class Product {
private $_options = array();
public function getOptions()
{ return $this->_options; }
public function addOption(Option $option)
{ $this->_options[] = $option;
return $this;
}
}
?>
//SHow all
<?php require('template/header.phtml') ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table class="datatable">
<tbody>
<?php foreach ($view->dd as $dvdDetails) {
echo '<tr> <td>'
.'<img src="images/'. $dvdDetails->getPhotoDetails() .'"alt="no picture" height="240" width="820" />' .'<br><br>'.'<font size="3" color="#2E2E2E"><center>'. $dvdDetails->getDvdPhoto(). '</center></font>'.
'<br><br><br>'. '<font size="2" color="blue"><strong>Genre: </strong></font>'. $dvdDetails->getDvdGenre() .
'<br><br>'. '<font size="2" color="blue"><strong>Director: </strong></font>'. $dvdDetails->getDvdDirector() . '<br><br>' .'<font size="2" color="blue"><strong>Ritels: </strong></font>'. $dvdDetails->getDvdRitels() .
'<br><br>' . '<font size="2" color="blue"><strong>Price for rent: </strong></font>'. $dvdDetails->getDvdId()) .
'<br><br>' .
'<div class="ghassar">' .
'<div id="op"> <label>Number of days </label> <select name="days" > <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option>
</select>
<br><br><br><br>
</div>
<div>
<input type="submit" value="Add to the basket" name="rent" id="buttom1" />
</div> ' . '<br><br>' .
'<br><br>' .'<div>'.
'</td> </td> </tr>';
} ?>
</tbody>
</table>
<?php require('template/footer.phtml') ?>
// 카트
<?php
require_once('Models/Dvd_sql.php');
require_once('Models/Shop.php');
$view = new stdClass();
$view->dd = 'SQL';
$dvd_sql = new Dvd_sql();
$view->dd = $dvd_sql->fetchAllStudents(); //->fetchAllStudents();
if (isset($_POST['rent']))
{
$tem = $_POST(['$dvdDetails->getDvdId()']);
$shop = new Shop(); $shop->addProduct($tem);
}
require_once('Views/dvdDetails.phtml');