Jump to content

Recommended Posts

Hi,

 

I am a noob here :)

 

Anyhow, here are my question. I have a database in flat file which consist

 

$var_one = "Whole wide world";
$var_two = "Everything you need";
$var_three = "Might be true";

 

In another file, let say index.php. It will call the db file. Let say index.php just have this code :

 

<?php echo $var_one ?>

 

 

How do I make search engine that looks for the variable in the database and display the file which associated with the term entered?

 

Meaning that if people search for term "whole", it will display index.php as a link and user can click the link.

 

Pardon my way of saying things.. I just not good at asking question.

 

 

Thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/140893-search-engineflat-file/
Share on other sites

That is a little more complicated than you may think that it is. Why don't you use a database? Also, this forum is to help you with code when you run into problems. No one is going to code something for you if you come up with something yourself someone will be more than willing to help you out when you run into problems.

Actually I have problem using the database..Let just say I can't use it..not that I don't want to.

 

Is this because you don't know how to or are having a problem setting it up?

 

I do know how to set it up. Problem is my admin does not want me using the database. I really do not understand that part myself. The only solution left is using flat file database.

 

As for the search engine. Currently working on it until I got stuck. Hope somebody will lend me a hand :P

You can't just echo $var_one and expect it to automatically search for it in your flatfile.  Variables only hold data.  You can have that data be code and then eval it if you really want to, but then you'd have to have one for every single variable in there.  you can write some code to load them into an array (or individual vars) so they would all be loaded up.  Or you can make a function that searches through the file and grabs the value and returns it, each time it is called.  Or you can make a class that does the same thing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.