tip850 Posted July 14, 2008 Share Posted July 14, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/ Share on other sites More sharing options...
ratcateme Posted July 14, 2008 Share Posted July 14, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589962 Share on other sites More sharing options...
tip850 Posted July 14, 2008 Author Share Posted July 14, 2008 I have no idea how to use mysql and it looks much more confusing then any other language I have seen. I know it's meant to be one of the easier languages but I just can't get my head around it. If you could help using mysql then I will try. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589968 Share on other sites More sharing options...
$username Posted July 14, 2008 Share Posted July 14, 2008 Yah its not to bad to pick up. And there are so many online docs that make it ez to pick up. Give it a shot works better than text files. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589970 Share on other sites More sharing options...
ratcateme Posted July 14, 2008 Share Posted July 14, 2008 read this it has a descent mysql and php tutorial http://www.tizag.com/phpT/ Scott. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589978 Share on other sites More sharing options...
tip850 Posted July 14, 2008 Author Share Posted July 14, 2008 What tool should I use to help me write mysql? Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589984 Share on other sites More sharing options...
$username Posted July 14, 2008 Share Posted July 14, 2008 Well your not really writing mysql language more like PHP for mysql. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589987 Share on other sites More sharing options...
tip850 Posted July 14, 2008 Author Share Posted July 14, 2008 My web hosting company gives me phpMyAdmin. Should I use that? Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-589990 Share on other sites More sharing options...
rondog Posted July 14, 2008 Share Posted July 14, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-590009 Share on other sites More sharing options...
tip850 Posted July 16, 2008 Author Share Posted July 16, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-591173 Share on other sites More sharing options...
ratcateme Posted July 16, 2008 Share Posted July 16, 2008 change your query to $query = mysql_query($search) or die(mysql_error()); it could be that your mysql query isn't working so myql_num_rows() wont work Scott. Quote Link to comment https://forums.phpfreaks.com/topic/114731-php-search-engine/#findComment-591202 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.