0
session_start();
$aaa=$_REQUEST['bb'];
$_SESSION['bookrec']=array(
'book1'=>array('callno'=>123005,'price'=>number_format(1380,2),'desc'=>'Attack on Titan Anthology','auth'=>'Scott Synder'),
'book2'=>array('callno'=>123006,'price'=>number_format(844,2),'desc'=>'Binge','auth'=>'Tyler Oakley'),
'book3'=>array('callno'=>123004,'price'=>number_format(598,2),'desc'=>'A Work in Progress','auth'=>'Connor Franta'),
'book4'=>array('callno'=>123003,'price'=>number_format(668,2),'desc'=>'The Amazing Book is Not on Fire','auth'=>'Dan Howell, Phil Lester'),
'book5'=>array('callno'=>123002,'price'=>number_format(760,2),'desc'=>'Children of Eden: A Novel','auth'=>'Joey Graceffa'),
'book6'=>array('callno'=>123008,'price'=>number_format(799,2),'desc'=>'Username : Evie','auth'=>'Joe Sugg'),
'book7'=>array('callno'=>123009,'price'=>number_format(440,2),'desc'=>'The Maze Runner','auth'=>'James Dashner'),
'book8'=>array('callno'=>123007,'price'=>number_format(572,2),'desc'=>'Anne Frank: The Biography','auth'=>'Melissa Muller'),
'book9'=>array('callno'=>123001,'price'=>number_format(699,2),'desc'=>'This Book Loves You','auth'=>'Pewdiepie')
);
$selected=array();
if($aaa=='book1') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book1']);}
if($aaa=='book2') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book2']);}
if($aaa=='book3') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book3']);}
if($aaa=='book4') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book4']);}
if($aaa=='book5') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book5']);}
if($aaa=='book6') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book6']);}
if($aaa=='book7') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book7']);}
if($aaa=='book8') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book8']);}
if($aaa=='book9') {$_SESSION['b']=implode("<td>",$_SESSION['bookrec']['book19']);}
if($aaa=='book1') {$_SESSION['bo']=$_SESSION['bookrec']['book1']['price'];}
if($aaa=='book2') {$_SESSION['bo']=$_SESSION['bookrec']['book2']['price'];}
if($aaa=='book3') {$_SESSION['bo']=$_SESSION['bookrec']['book3']['price'];}
if($aaa=='book4') {$_SESSION['bo']=$_SESSION['bookrec']['book4']['price'];}
if($aaa=='book5') {$_SESSION['bo']=$_SESSION['bookrec']['book5']['price'];}
if($aaa=='book6') {$_SESSION['bo']=$_SESSION['bookrec']['book6']['price'];}
if($aaa=='book7') {$_SESSION['bo']=$_SESSION['bookrec']['book7']['price'];}
if($aaa=='book8') {$_SESSION['bo']=$_SESSION['bookrec']['book8']['price'];}
if($aaa=='book9') {$_SESSION['bo']=$_SESSION['bookrec']['book9']['price'];}
foreach($_SESSION['bookrec'] as $data){
if($data == $_SESSION['bookrec']['book1']) {
$selected[]=$_SESSION['bo'];
echo "<table class='w3-table w3-khaki'><tr><td> ".$_SESSION['b']."</td></tr></table>";
}
}
echo "<center><b>TOTAL AMOUNT:</b> Php ".number_format(array_sum($selected),2)."</center>";
?>
私は、このコードに問題を抱えている...私は、カートにアイテムを追加すると、それは、カートにアイテムを保持するが、セッション - Webcart
を言ってエラーがありますNotice: Undefined index: bb in C:\xampp\htdocs\Webcart_ch\Webcart\mycart.php on line 85
インデックス 'bb'がチェックボックスにある場合、チェックボックスがオンになっていると、コンテンツが出力されます。私は本当にそこに着いているが、私は何をすべきか分からない!助けてください..
サイドノート、あなたは' $ _SESSIONを行うことができるはず[' B '; $ _ SESSION [' bookrec '] [$ aaa] 'と$ _SESSION [' bo '] = $ _ SESSION [' bookrec '] [$ aaa] [' price '];'すべてのifステートメントの – Rasclatt