hi, im trying to do a search on my Array, where a users searches on a HTML screen and then the PHP searches the array for the data under the roice entred by user.....text file data is under the php code
[PHP]
<HTML> <BODY>
<?
$filename = "cdlist.txt";
$filepointer = fopen($filename,"r"); // open for read
$cdArray = file ($filename);
//phpfields.php
if (!(isset($_POST['usersearch']))) {exit;}
$search = $_POST['usersearch'];
print "User typed in $search <br>";
// ANODA FOR LOOP ADN ADD IF STATEMENT TO GO THRU D ARRAY DEN TAKE IT BAKUP
// go through the data form txt file, then put it in a string
// and then do a if statement saying if users serach matches with
// string then display, else exit
for ($newcount = 0; $newcount < count ($cdArray); $newcount++)
{
$newstring = getvalue($newcount,3);
$newaline = $cdArray [$newcount];
//print "$cdArray $newcount<br>";
// print "$newaline <br>";
if ($search < $newaline[3])
//$newaline[3] < 4 is the position for the price
{
print "$newaline <br>";
}
else
{exit;}
// { print "no results found, please search again <br>"; }
}
fclose ($filepointer);
function getvalue ($text, $commaToLookFor)
{
$intoarray = explode(",",$text);
return $intoarray[ $commaToLookFor];
}
if (!($filepointer = fopen($filename,"r"))) { exit; }
?>
</body>
</html>
[/PHP]
text file data is ...
Artist, Title, Year, Price, StockLevel
Usher, The Masterpiece, 2007, 9.99, 1
snoop, dog pound, 2000, 10.99, 4
Snoop Dogg, Doggystyle, 1993,12.99, 6
Dr. Dre, 2001, 1999, 12.99, 10