ID 배열이있는 세션이 있습니다. 이 id는 ($ sessionarray의 id를 사용하여) 견적 페이지에 제품을 표시하는 데 사용됩니다. 이제 제거 아이콘을 추가하고 해당 링크를 클릭하면 ID를 제거하고 싶습니다. 이 자바 스크립트를 사용하지 않고 할 수 있습니까?href 클릭시 세션의 배열 값 설정 해제.
모든 제품과 같이 내 쿼리에서로드 :
설명에 링크가 나는 ID가 (배열입니다) 세션에서 제거하고 싶은 누르면if(count($_SESSION['product']) == 0){
echo 'No products added';
}else{
foreach($offertecr as $product){
if (strlen($product['introtext']) > 100){
$shortcat = substr($product['introtext'], 0, 100) . '...';
}else{
$shortcat = $product['introtext'];
}
$offerte_imgs = $product['image_intro']; // Get image parameters of the article
$offertepic = json_decode($offerte_imgs); // Split the parameters apart
if($offertepic->{'image_intro'} != ''){
$image = 'cms/'.$offertepic->{'image_intro'};
}else{
$image = 'http://www.website.nl/_extern/web/cms/images/Producten/Untitled-7.jpg';
}
if($product['id'] != ''){
$offerteoverzicht .= '
<div class="row productofferte">
<div class="col-md-6 offerteimg">
<img src="'.$image.'">
</div>
<div class="desc">
<p style="font-weight:bold;">'.$product['title'].' <a href="#"><i class="fa fa-times" aria-hidden="true"></i></a></p>
<p>'.$shortcat.'</p>
</div>
</div>';
}
}
}
.
코드 나는 (있는 나는 그것이 효과가 두 번 제거 버튼을 눌러야합니다) 사용 :
if(isset($_GET['id'])){
$productID = $_GET['id'];
$key=array_search($_GET['id'],$_SESSION['product']);
if($key!==false)
unset($_SESSION['product'][$key]);
$_SESSION["product"] = array_values($_SESSION["product"]);
}
예 수 서버로의 왕복 여행과 페이지 다시 칠하기가 포함됩니다. – RiggsFolly
@ RiggsFolly 작동하려면 코드를 다시 실행해야한다는 의미입니까? – twan
기본적으로 내가 암시 한 내용을 다루는 답변이있는 것 같습니다. 그게 작동하는지 확인하십시오. – RiggsFolly