Search Engine through PHP
Hi,
This is my third script that I have a small problem:
My search engine.
Here's the script search form:
Code:
<code type="php">
<form method="POST" action="recherche.php">
Enter a keyword: <br>
<input type="text" name="Mot" size="15">
<input type="submit" value="Rechercher" alt="Lancer the recherche!">
</ form>
</ code>
Here's the script display search results:
<code type="php">
<? php
$ host = localhost;
$ user = "root";
$ password = "";
$ db = "abcfibromyalgie";
mysql_connect ($ host, $ user, $ password) or die ( "Connection to server");
/ / We choose the correct basis
mysql_select_db ($ db) or die ( "Connecting to db");
echo "
<html>
<head>
<title> Search Results </ title>
</ head>
<body> ";
if (($ "")||($ Word word == == ("%"))
/ / If a keyword has been seized,
/ / Script asks the user
/ / Kindly specify a keyword
echo "
Please enter a keyword please!
<p> ";
)
else (
/ / On selected records containing the keyword
/ / Or keywords in the title
$ query = "SELECT distinct count (link) FROM search
WHERE keyword LIKE \ "Mot% $% \"
OR LIKE title \ "% $% word \"
";
$ result = mysql_query ($ query);
$ row = mysql_fetch_row ($ result);
$ Number = $ row [0];
/ / If no record is returned
/ / Displays a message appropriate
if ($ Number == "0") (
echo "
<h2> No results matched your search </ h2>
<p>
";
)
/ / Otherwise, it displays the number of records corresponding
/ / And the results themselves
else (
$ query = "SELECT distinct link, keyword, title search FROM
WHERE keyword LIKE \ "Mot% $% \"
OR LIKE title \ "% $% word \" order by title ASC ";
$ result = mysql_query ($ query);
/ / If only one record is found, it displays a message in the singular
if ($ Number == "1") (
echo "
<a name=\"#resultat\"> <h2> Result: An article found </ h2> </ a>
<p> ";
)
/ / In case the message is plural ...
else (
echo "
<a name=\"#resultat\"> <h2> Result: $ Number items found </ h2> </ a>
<p> ";
)
while ($ row = mysql_fetch_row ($ result))
(
echo "
<p> \ n
<b> $ row [2] </ b> \ n
<br> <a href=\"../$row[0]\"> View article </ a> \ n
<p> \ n
";
)
)
)
/ / On the firm basis
mysql_close ();
>
</ body>
</ html>
</ code>
Here is the first code of BDD:
<code type="sql"> --
--
- Structure of the table `search`
--
CREATE TABLE `search` (
`link` varchar (128) NOT NULL,
`` keyword text,
`title` varchar (128) default NULL,
`id` int (11) NOT NULL default'0 ',
PRIMARY KEY ( `id`)
) ENGINE = InnoDB DEFAULT CHARSET = latin1;
</ code>
Here the problem is that when I type a word into a search engine that I and my valid request, I see no results even if the word is that BDD is present
So if some of you have a solution.
Thank you in advance ...