Php 从文本文件递增/添加数据
我有一个网页,其中包含一些文本文件中的数据,选中时会在不同的页面上显示选中的数据。 每次选中复选框时,我想增加访问字段,如何在每次访问时增加变量“$visit”并将其保存到文本文件中 new.phpPhp 从文本文件递增/添加数据,php,arrays,sqlite,checkbox,Php,Arrays,Sqlite,Checkbox,我有一个网页,其中包含一些文本文件中的数据,选中时会在不同的页面上显示选中的数据。 每次选中复选框时,我想增加访问字段,如何在每次访问时增加变量“$visit”并将其保存到文本文件中 new.php <html> <body bgcolor="#99FF00"> <table border="1"> <FORM ACTION="new.php" METHOD="POST"> Enter maximum price <input type="
<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>
关于如何在web上执行此操作,有多个教程 这里有一个很棒的教程: 当然,每次选中复选框时递增将需要一些AJAX脚本。 除非您正在等待post数据通过,然后更新计数器