473,775 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP - maximum price search on a text file

37 New Member
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($newco unt,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(",",$te xt);
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 2036
pbmods
5,821 Recognized Expert Expert
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
2107
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 XSLT. The result for the example (searching for <A/>) should be 4 as the element A is nested 4 times maximum. I guess I have to use somehow the count function with 'following::A' axes. But I could not get that to work yet.
12
11946
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 system in text format. I found a website that's doing it, but don't know where to start in reverse engineering the code: http://www.goldinvestment.com/Purchasing/Scrap_Gold.asp Thanks
11
24145
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 memchr(), memcmp(), memmove() a lot. Is there an ANSI C maximium size for character arrays which are guaranteed to succeed, assuming the machine has sufficient memory? And will the memxxx() functions work with that size? I'm looking at hopefully...
5
4363
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
2942
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 cannot access files via any i/o operations, I have written a routine in Delphi. It parses files in one folder and generates a Javascrip tfile. The first lines build up a file table, then the word index is build.
3
3558
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 other Windows flavors. Procedure: 1. Create a simple text file named test.txt. 2. Open the text file in a text editor and add a simple test word such as "blah" (not quotes).
0
1541
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 when researching the problem? A simple pattern for finding the maximum value in a file, using only plain Python code, is:
1
3373
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 separated value). I was trying to do this by using python (usually i work with fortran or bash, but i'm learning python), that the reason why i tried to use numpy. Fredrik Lundh wrote:
0
10781
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 inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
9622
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.