Knowledgebase

Portal Home > Knowledgebase > Articles Database > Making my own search engine with PHP from scratch


Making my own search engine with PHP from scratch




Posted by Kolusion, 08-23-2011, 01:28 AM
I am creating a search form and wondering if my idea is possible with PHP. The search form will comprise of many entries, but to keep this thread simple, I am going to keep things at minimal. The directory structure of my web server is like this: %root%/products/A/1/ It will look something like this: In each product directory (%root%/products/A/1/), I am going to have a file called "index.lodb". This will be a kind of registry file that will look like this: The search form will have these question: The form is then submitted to "search.php" which is the engine I guess that will perform the search and return results as include(index.listing). These listing files contain a small amount of HTML, such as an image of the product and a little text description about it. The result of this process will compile a list of all the products which matches the search query. One problem I can see already is that if a product matches with two inputs, such as 'colour' and 'price', then the result will be include()d twice. I would need to some how do something like if its already been included, to omit another include() of it. A little bit about my background: I know intermediate HTML/CSS and I just started using PHP a few days ago. I know a little bit about Python and have coded a similar script before for converting postcode to power distributor/electricity rates. I was a telemarketer in my previous job and I was fedup with my IE6 interface. The issue with the script was that everything was in a single file which I had to write up manually.. I have forgot exactly how I did it as I learn't Pyhton specifically for it and have never used it since, but it went something like: Manually writing up a database was tiring and inefficient. With the way I am using now, I won't have to manage any database, just create a .lodb and .listing file for the product, and when the product is sold I just have to move the product directory out of the WWW directory and thats it, its detached from my site. What I am asking is someone can give me a direction where to learn how to do this, or where I can find example code to study and learn from. Thanks.

Posted by Kolusion, 08-23-2011, 04:35 AM
Never mind. Last edited by Kolusion; 08-23-2011 at 04:42 AM.

Posted by Kolusion, 08-23-2011, 10:09 AM
Actually, I'm back using PHP. MySQL totally ****ed my mind!

Posted by Jatinder, 08-24-2011, 02:13 AM
Have you tried out Zend Lucene? It works pretty well for small to medium websites. Solr is another alternative.

Posted by cagoon, 08-24-2011, 10:03 AM
Searching through files is extremely inefficient. You're way better off with a SQL database. Sure it's another thing you'll need to learn but in the long run, it'll pay off.

Posted by Mambug, 08-24-2011, 10:55 AM
I would strongly suggest SQL. You can do something similar to what your looking to do though. Write a PHP script that enables you to upload your product on the form. Essentially what the PHP script will do is: 1) Take your 'image' and move it to the corresponding directory 2) Insert an entry into the SQL database with the location, and information Then, when you write your PHP search script, simply search the SQL for table entries matching your specified values, and on return, parse the location that was stored in the SQL table as code (or translate it to code) to retrieve the images. Done!

Posted by activechase, 08-27-2011, 03:48 PM
I would develop project like that with codeigniter

Posted by fireboltz, 08-29-2011, 06:09 AM
Good. Check with the security reasons. dont forget about it



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Apache High Load (Views: 607)
Smtp (Views: 520)


Language:

Contact us