2012-02-26 2 views
0

텍스트 파일의 일부 데이터가 포함 된 웹 페이지가 있는데,이 확인란을 선택하면 선택한 데이터가 다른 페이지에 표시됩니다. 체크 박스를 체크 할 때마다 방문 필드를 증가시키고 싶습니다. 방문 할 때마다 변수 "$ visit"을 어떻게 늘려 텍스트 파일에 저장합니까?텍스트 파일에서 데이터 증가/추가

new.php

<html> 
<body bgcolor="#99FF00"> 
<table border="1"> 
<FORM ACTION="new.php" METHOD="POST"> 
Enter maximum price <input type="text" name="maximumprice"/> 
<p><input type="submit" value="Go" name="Go"/> 
</form> 

<? 

$mPrice = $_POST['maximumprice']; 
$file1 = "properties.txt"; 
$filedata = fopen ($file1, "r"); 
$array1 = file ($file1); 

print "<form action=\"visit.php\" method=\"POST\">"; 




for ($counter1 = 0; $counter1 < count($array1); $counter1++) 
{ 
$arrLine = $array1[$counter1]; 

$pCode = getvalue ($arrLine, 0); 
$price = getvalue ($arrLine, 1); 
$picture = getvalue ($arrLine, 2); 
$visit = getvalue ($arrLine, 3); 



if ($price < $mPrice) 
{ 
print "<tr>"; 
print "<td>"; 

print $pCode. "<br>"; 
print $price. "<br>"; 
//print $picture. "<br>"; 
print $visit. "<br>"; 

print "<input type=\"checkbox\" name=\"box[]\" value=\"$arrLine\" />"; 

print "</td>"; 

print "<td>"; 
printf("<img src='$picture' width='200' height='150'>"); 
print "</td>"; 
print "</tr>"; 


} 
} 

print '<input type="submit" name="Visit" value="Visit"/>'; 

// Move the form outside the for loop 
print "</form>"; 


fclose ($filedata); 

function getvalue ($text, $arrNo) 
{ 
$intoarray = explode (",", $text); 
return $intoarray[$arrNo]; 
} 

?> 

</table> 
</body> 
</html> 

이 두 번째 페이지입니다 display.php

<html> 
<body bgcolor="#99FF00"> 
<? 

foreach ($_POST['box'] as $values) 
{ 
echo "$values <hr/>"; 
} 



?> 
</body> 
</html> 

답변

0

웹에서이 작업을 수행하는 방법에 대한 몇 가지 튜토리얼이 있습니다. 매번 약간의 AJAX 스크립트가 필요합니다 체크 체크 박스를 증가 물론 http://www.developingwebs.net/phpclass/hitcounter.php

:

좋은 자습서는 여기에 하나입니다. 게시물 데이터가 오기를 기다리지 않고 카운터를 업데이트하지 않는 한.