Some text databse help please

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

liquidchaz
New php-forum User
New php-forum User
Posts: 3
Joined: Sun Feb 02, 2003 10:25 pm

Some text databse help please

Postby liquidchaz » Sun Feb 02, 2003 10:37 pm

While I am an fairly experienced programmer (Java, C/C++), I warning everyone now that I'm a COMPLETE PHP newbie.

Anyway, my college radio station asked me to make their catalog of music searchable on their website. As far as I know, the server is not capable of handling SQL stuff (hey, affordable hosting, what do you expect?). So, I've had them put everything in a text file in this format:

artist, name of song
michael jackson, thriller
bob marley, redemption song

etc, etc.

I was wondering if someone could help me write a simple search script for this text file and then display the results in an web page. I would like them to search by artist's name, the name of the song, or both. I also would like to handle substrings (ie: the query "jack" returns all the songs by Michael Jackson, Janet Jackson, Jackson 5, etc.).

Is there anyone out there willing to write this basic script?

As I said, I am not familiar with PHP at all, but I am a programmer. So after the framework is layed for this script, I'm positive I could edit it to my needs.

Thank you all very much in advance.

Charles

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sun Feb 02, 2003 11:29 pm

algoritm...

1) search word converting to lower case
2) SELECT from mysql by REGEXP '%searchword%'
3) print results

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Sun Feb 02, 2003 11:48 pm

He's not using a database so select statements won't work.


How many items are going to be in your files. Because there is no indexing it may go very slow with increased traffic and a large catalog.

anyways.. if you are firmilar with java/c++ then you should be firmilar with arrays which work pretty much the same way in PHP. http://www.php.net/array for more info anyways .

Code: Select all

$file = file('filename.txt');


that reads the contents of the filename.txt file into the array named $file.

Each index of the array contains a line from the file.

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

UPS! =)

Postby Oleg Butuzov » Mon Feb 03, 2003 12:45 am

soory =)

in your way

eregi ("$searchword", $file[$numrow]);


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

cron