Web Hosting Talk







View Full Version : Looking for a CGI/PHP script, PLEASE HELP!!! thnkz


dazz
12-23-2002, 07:01 AM
This is kinda hard to explain, but I will try my best!!
I need a PHP/CGI script that will search a text file, and search it in a specific way.

Hears an example of the text file...

____________________________________________________

-- http://www.yahoo.com/ --
[ yahoo, search, internet ]

-- http://www.microsoft.org/ --
[ microsoft, windows xp, support, internet ]

-- http://www.mcdonalds.com/ --
[ food, good ]

____________________________________________________

So if somone does a search for lets say "yahoo". They will recieve a rsult on another page:
-- http://www.yahoo.com/ --

They would recive this result because the keyword "yahoo" is below http://www.yahoo.com

Or if they do a search for "internet" they will recieve the result:
-- http://www.yahoo.com/ --
-- http://www.xp-erience.org/ --

They would recieve this because the keyword "internet" is under http://www.yahoo.com/ and http://www.xp-erience.org/


Thats the best i can explain it, im not gonna use urls for it, just some other stuff alike it, has 100's of them if you know of a script that would do this, that would be great!!

only if its free tho....

thanks allot :d This will help myself out LOTS LOTS LOTS
THANKS again

Rich2k
12-23-2002, 08:02 AM
Umm do you not have access to a sql compliant database? This would make life SOOOO much easier!

MarkIL
12-23-2002, 08:37 AM
This snippet will search the file and return all matches.


function GrepFile($s='',$file='')
{
if (!strlen($s) || !file_exists($file) || !is_readable($file) || !filesize($file)) return array();
$f = file($file); $ret = array();
foreach($f as $k=>$v)
{
if ($v[0] == '-') $lasturl = substr($v,3,strlen($v)-3);
else
{
$dsc = explode(',',trim(str_replace(array('[',']'),'',$v)));
if (in_array(strtolower($s),array_keys($dsc)) $ret[] = strtolower($lasturl);
}
}
return $ret;
}


But still, you should REALLY consider using a database to store and index the data.

dazz
12-23-2002, 08:19 PM
i see that code above, and i have no idea where to start!

i do have a mysql database if thats what you mean to use, i would use it if i knew how tho!

:rolleyes: :rolleyes:

Thanks, if you could help me on this u would be the BEST!!

dazz
12-27-2002, 08:00 PM
please please help me

barrywien
12-27-2002, 09:10 PM
Hi
If you do not have the experience in either PHP or CGI to be able to edit/design a script to meet your needs then I suggest you post in the Job Offers and Requests section and put up some $$$. I am sure you will get a lot of responce there.

dreamrae.com
12-28-2002, 03:52 AM
lol @ thread

acidhoss
12-31-2002, 08:52 PM
Ooooor, you could take some time and NOT spend any money, learn MySQL (which is fairly easy) and learn php (also, very easy), by going to these sites:
www.devshed.com<=click on php tutorials,
http://www.atlasindia.com/sql.htm<=very good my sql tutorials
try it, you'll thank me when you know PHP, and mysql and you didn't have to spend any money