Jump to content

Recommended Posts

Hi, this is my first thread and I am new to the whole web design business.

 

How could I make a pure PHP search engine to search the site that I am making? I don't want to use mysql just PHP, HTML and if I have to text files. I have tried to record information in text documents but I couldn't find a way to get the information.

 

I searched through php.net and all I found was a few string function that couldn't search the whole file, once it found the word I was looking for it stopped searching.

 

The first thing I need to know is how should I record the information without using mysql?

 

I have made the form that will gather the information I need and it sends it all to my email and the file it uploads gets sent to a folder named "assignments". There are nine fields, eight of them return text and the other file upload field returns what ever file is uploaded; there are no restrictions on the uploaded file and even if it is a text document I don't want the search engine to search it.

 

The second thing I need to know is how to search for the information?

 

I don't care if there needs to be a seperate file to store the information for each time something new is submitted. I have created a table using html and php which will be where the results go. Each part of the table echos a varible. If I can't put the code on the same page as the table which visitors will see then I also need to know how to get varibles from other files.

 

I want the most relivant information at the top of the table and to work out the relivance of the information I want the search engine to figure out what percentage of the document contains the words that the user searched for.

 

The last thing I need to know is what do I do when the search engine returns more results then I can fit on 1 page (there are 10 results per page)?

 

Thanks in advance to any one who answers my questions. This has been driving me nuts for the last week. I was tring to get the website live before the 20th of June but I didn't expect the search engine to be such a road block. It's the only thing left that I havn't finished. I have tried downloading search engines already made but they are not personilised enough, some of them contain foreign adverising and I can't edit them at all.

 

Thanks,

 

Tim

Link to comment
https://forums.phpfreaks.com/topic/114731-php-search-engine/
Share on other sites

why are you doing this without mysql for a complete newbie i would say use nothing other than mysql. what you are trying to do is insanely hard and will take an extremal long time to go through text files every time someone presses the search function.

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589962
Share on other sites

yeah phpMyAdmin is good. Thats what I learned mysql on the first time. Its actually pretty easy. Their is really no "code" writing in mysql..its more of a command line.

 

SELECT * FROM users

 

that would select all the information in the users table.

 

in php it would simply be:

 

<?php

$query = mysql_query("SELECT * FROM users");

//or even

//this would get just a single row where the id is equal to whatever is in the url bar
$query = mysql_query("SELECT * FROM users WHERE id = '".$_GET['id']."'");

?>

 

Its pretty easy once you get a handle on it. I'd suggest learning MySQL. The method you are talking about in searching is just not practical.

Link to comment
https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-590009
Share on other sites

I took a lot of peoples advice and decided to try to learn mysql and so far I managed to put information into the database and retrieve it but I am stuck doing something with the information.

 

Here is the part where I send the information to the database

mysql_connect("localhost","web177-tip850","peoples850");
mysql_select_db("web177-tip850");
mysql_query("INSERT INTO assignments(assignment_name, assignment_description, school, year, catagory, document, mark, year_marked, credits)VALUES('$name', '$description', '$school', '$year', '$catagory', '$file', '$mark', '$yearmarked', '$credits')") or die(mysql_error());
mysql_close();

 

That part of the code works.

Do I have to close the mysql connection or does it close itself?

 

This bit is the part where I try to retrieve the information and do something with it. For some reason the mysql_num_rows part doesn't work.

$search_box = $_REQUEST['search_box'];
mysql_connect("localhost", "web177-tip850", "peoples850") or die(mysql_error());
mysql_select_db("web177-tip850");
$search = "SELECT*FROM assignments WHERE (assignment_name, assignment_description) LIKE $search_box ORDER BY assignment_name";
$query = mysql_query($search);
$no_rows = mysql_num_rows($query);

 

Why doesnt the mysql_num_rows work?

 

All I have to do now is put the results into a table but there will be more then 1 page of results with ten results per page. How do I make more pages but have the table on the second page continue on from the first and the third continue on from the second and so on? I used the mysql_num_rows to determine how many pages the script will need to make.

 

I think I will need to use mysql_result to put the information into the table but to use that I need to know what row of information I need. How do I figure out what row I need?

 

Link to comment
https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-591173
Share on other sites

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.