Simple Search Engine php
I have mentioned in previous tutorials how to search data in a database.Now we can move on to making simple search engine.For this tutorial also need to have data base table called search.Make search table in your my_database using following guide.
CREATE TABLE IF NOT EXISTS `search` (
`id` int(40) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`link` varchar(255) NOT NULL,
`description` longtext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Then make search input file called search.php
wintekweb php
free php scripts,wintekweb.blogspot.com/2012/06/joining-3-tables-php-mysql.html 8 Jun 2012 ?Get Visitors IP Address PHP - wintekweb php
free php scripts,wintekweb.blogspot.com/2012/05/get-visitors-ip-address-php.html 30 May 2012 ? web statistic is very important when you start your own site.web statistics mainly consist of page views today,yesterday,last month &all history ...AND Search php - wintekweb php
free php scripts,5 Jun 2012 ? Php scripts,php mysql,Create Database ,Drop Database,Create Database, Incert, Displaying Data, PHP MySQL Update.<html> <head> <title>Search Engine </title> </head> <body> <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table align="center"> <tr><td colospan=2><img src="win.png"></td></tr> <tr><td><input name="search" type="text" id="search" size="50"></td><td><input type="submit" name="Submit" value="Search >>"></td></tr> </table> </form> <?php $search=$_POST['search']; $con = mysql_connect("localhost","root","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_database", $con); $result=mysql_query("select * from search WHERE title LIKE '%$search%' OR description LIKE '%$search%'"); $num_rows = mysql_num_rows($result); while ($row = mysql_fetch_assoc($result)){ echo "<font color=#418dce><H4><a href=$row[link]>".$row['title']."</a></H4></font>"; echo $row['description']."</br>"; } ?> </body> </html> |
Nice example. It is very simple and easy to understand exactly what is simple php scripts. Thanks for sharing.
ReplyDeleteI actually enjoyed reading through this posting.Many thanks.
ReplyDeleteSearch Engine Optimization New Jersey