I have a text file called comment.txt, which says:
file text 300 a
file text 600 b
file text 700 c
file text 500 d
and what I want to do is display all comment details below a maximum price. The user will enter the price in a field on a static web form - the price is read in by the script and used to find the comment details as the script reads through the comment text file.
This is my code:
<HTML><BODY>
<?php
#reads a text file and outputs it to screen
$prices = $_POST['price'];
$filename = "comment.txt";
$filepointer = fopen($filename, "r"); //open for read
$myarray = file ($filename);
for ($mycount = 0; $mycount < count($myarray); $mycount++)
{ //one line at a time
$aline = $myarray[$mycount];
$partdetails = getvalue($aline);
print $partdetails[0]." <br>";
print $partdetails[1]." <br>";
print $partdetails[2]." <br>";
print $partdetails[3]." <br>";
}
$myprice = 0
if ($myprice == $prices)
{
print = "the prices below $prices";
}
fclose ($filepointer);
function getvalue ($text)
{
$intoarray = explode(",",$text);
return $intoarray;
}
// if (!($filepointer = fopen($filename,"r"))) { exit; }
?>