Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Some text databse help please

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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.

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

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


1) search word converting to lower case
2) SELECT from mysql by REGEXP '%searchword%'
3) print results
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

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. 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
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA

UPS! =)

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

soory =)

in your way

eregi ("$searchword", $file[$numrow]);
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.