php search engine script for mysql database

php search engine script for mysql database

Today, We want to share with you php search engine script for mysql database.In this post we will show you How to create your own search engine with PHP and MySQL, hear for Create Your Own Search Engine Using PHP, jQuery And MySQL we will give you demo and example for implement.In this post, we will learn about Creating a simple search algorithm with PHP and MySQL with an example.

php search engine script for mysql database

There are the Following The simple About php search engine script for mysql database Full Information With Example and source code.

As I will cover this Post with live Working example to develop Building a Search Engine in PHP and MySQL, so the Create A Search Engine In PHP, MySQL for this example is following below.

  Ajax Login System with jQuery PHP and MySQLi

Setp 1: HTML SourceCode

We have to simple copy and paste the source code below in to index.php

<html>
<head>
<title>Title of your search engine - pakainfo.com</title>
</head>
<body>
<form action='search.php' method='GET'>
<center>
<h1>Pakainfo - Search Engine</h1>
<input type='text' size='90' name='search'></br></br>
<input type='submit' name='submit' value='You have simple Search source code' ></br></br></br>
</center>
</form>
</body>
</html>

STEP:2 PHP Code

and then you have to simple copy and paste the source code below inside the search.php

<?php
 
$button = $_GET ['submit'];
$search = $_GET ['search']; 
 
if(!$button)
echo "you didn't submit a keyword";
else
{
	if(strlen($search)<=1)
	echo "Search term too short";
	else{
		echo "You searched for <b>$search</b> <hr size='1'></br>";
		mysql_connect("localhost","root","[email protected]");
		mysql_select_db("live_search_engine");
		 
		$all_data = explode (" ", $search);
		 
		foreach($all_data as $find_data)
		{
			$x++;
			if($x==1)
			$query_str .="keywords LIKE '%$find_data%'";
			else
			$query_str .="AND keywords LIKE '%$find_data%'";
		 
		}
		 
		$query_str ="SELECT * FROM searchengine WHERE $query_str";
		$run = mysql_query($query_str);
		 
		$search_total_records = mysql_num_rows($run);
		 
		if ($search_total_records==0)
		echo "dear very Sorry, there are no matching result for <b>$search</b>.</br></br>1. 
		Try more any useful general words. for example: If you want to search 'how to create a blogspot'
		then use general keyword like 'create' 'blogspot'</br>2. Try different words with similar
		 meaning</br>3. Please check your right spelling";
		else
		{
			echo "$search_total_records results found !<p>";
		 
			while($dataRow = mysql_fetch_assoc($run))
			{
				$title = $dataRow ['title'];
				$desc = $dataRow ['description'];
				$url = $dataRow ['url'];
				 
				echo "
				<a href='$url'><b>$title</b></a><br>
				$desc<br>
				<a href='$url'>$url</a><p>
				";
			}
		}
	 
	}
}
 
?>

Web Programming Tutorials Example with Demo

Read :

  Create time slot using PHP Example

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about php search engine script for mysql database.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

avatar
  Subscribe  
Notify of