다음 코드가 있습니다. 선택한 항목을 추적하고 배열에서 표시하려고합니다.PHP 항목에 항목이 없습니다?
<?php
session_start();
//temp stores the submitted value
$temp = $_POST['field'];
if (!isset($_SESSION['itemsList'])) {
$itemsList = array();
} else {
$itemsList = $_SESSION['itemsList'];
}
//check how many elements in array
$arraySize = count($itemsList);
//set that as i and then add after that
$emptyval = "";
if (strcmp($temp,$emptyval)!=TRUE) {
array_splice($itemsList, $arraySize+1, 0, $temp);
unset($temp);
unset($_SESSION['field']);
$_SESSION['itemList'] = $itemList;
}
?>
<html>
<head>
<title>Test Page Khalid</title>
</head>
<body>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<table height="100%" width="100%" cellspacing="10" cellpadding="10" border="1">
<tr>
<td align="center"><input name="field" value="shirt" style="width:200px; height:100px;" type="submit"/></td>
<td align="center"><input name="field" value="pants" style="width:200px; height:100px;" type="submit"/></td>
<td align="center"><input name="field" value="socks" style="width:200px; height:100px;" type="submit"/></td>
<tr>
<tr>
<td align="center"><input name="field" value="dress" style="width:200px; height:100px;" type="submit"/></td>
<td align="center"><input name="field" value="skirt" style="width:200px; height:100px;" type="submit"/></td>
<td align="center"><input name="field" value="topbody" style="width:200px; height:100px;" type="submit"/></td>
<tr>
<tr>
<td align="center"><input name="field" value="sheets" style="width:200px; height:100px;" type="submit"/></td>
<td align="center"><input name="field" value="pillowcover" style="width:200px; height:100px;" type="submit"/></td>
<td align="center"><input name="field" value="blanket" style="width:200px; height:100px;" type="submit"/></td>
<tr>
</table>
</form>
<br><br><br>
<?php
$itemsReturned = $_SESSION['itemList'];
echo "The items stored are: <br>";
print_r($itemsReturned);
?>
</body>
</html>
이 아무것도 표시되지 않는 이유 어떤 생각? 감사합니다,
당신은 '아무것도 표시되지 않는'무엇을 의미합니까? 아무것도 전혀 오지 않는가요? – Gricey
오류보고를 사용하면 사람들이 더 많은 도움을 제공 할 수 있습니다. – Jim
일상적인 디버깅 작업을 시도한 다음 해당 정보를 제공하십시오. 변수를 설정하는 IF 블록으로 들어가는가? 그렇다면 설정 한 직후 가치는 무엇입니까? IF- 블록 직후는 어떻습니까? – Dave