473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

PHP - maximum price search on a text file

37
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
Oct 23 '07 #1
1 2018
pbmods
5,821 Expert 4TB
Heya, 848lu.

Have a look at fgetcsv().

You might also want to consider storing your data in a database.
Nov 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: KemperR | last post by:
Dear All, may be some of you can help me with an XSLT example how to solve the following challange. For the XML below I want to find out the maximum hierarchy level for a specific element in my...
12
by: | last post by:
Does anyone know an easy way to put a current gold price on your own website? I've seen the graphic methods that Kitco.com offers, but I'd rather have it pull the value from some gold market...
11
by: Walter Dnes (delete the 'z' to get my real address | last post by:
I've noticed a few threads (full of sound and fury, signifying nothing) here recently about allocation of large memory blocks. I'm about to start on a personal pet project where I'll be using...
5
by: Gerrit | last post by:
Hi all, I'm getting an OutOfMemoryException when I initialize a byte array in C# like this: Byte test = new Byte; I'm using ASP.NET 2.0. In ASP.Net 1.1 it works fine. So what am I doing
3
by: ckirchho | last post by:
Hallo, my task is to establish some kind of full text file search in Javascript. The files and it's contents are fixed, the HTML/JavaScript pages lie offline on a server. As far as Javascript...
3
by: =?Utf-8?B?UGVycmlud29sZg==?= | last post by:
Not sure where to post this... Found some interesting behavior in Windows Search (Start =Search =All files and folders =search for "A word or phrase in the file:"). This applies to XP and maybe...
0
by: Fredrik Lundh | last post by:
maurizio wrote: What kind of file is it? Did you pick numpy because you want to do matrix operations (beyond just finding a maximum value), or was it just the first thing you stumbled upon...
1
by: maurizio | last post by:
thank you for your answer actually i've to do some statistics (maximum,minimum,mean,standard deviation,....) of a file of data in which each column is a particular type of data. (the file is a tab...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.