Current location: Hot Scripts Forums » Programming Languages » PHP » Simple PHP Search Script needed


Simple PHP Search Script needed

Reply
  #1 (permalink)  
Old 12-30-05, 05:38 PM
sohaib sohaib is offline
Newbie Coder
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Simple PHP Search Script needed

hello,

I will be really gratefull if any one could direct me or make me a simple php search script which will read the following content in my mysql file i.e.

CREATE TABLE IF NOT EXISTS tblLinks (
`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`URL` VARCHAR(255) UNIQUE NOT NULL,
`Title` VARCHAR(255),
`Keywords` VARCHAR(255),
`Description` VARCHAR(255),
`ModifiedDate` DATE DEFAULT '0000-00-00' NOT NULL) TYPE=MyISAM;

INSERT IGNORE INTO tblLinks (`URL`,`Title`,`Keywords`,`Description`,`ModifiedD ate`) VALUES
('http://www.page1.com','Page1_Title','Page1_Keywords','Pag e1_Description',CURDATE()),
('http://www.page2.com','Page2_Title','Page2_Keywords','Pag e2_Description',CURDATE()),
('http://www.page3.com','Page3_Title','Page3_Keywords','Pag e3_Description',CURDATE())


Search display would be like google - only 10 results per page and than next previous page.

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-31-05, 09:29 PM
tophat's Avatar
tophat tophat is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Michigan
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
well, first of all, there are a lot of search scripts out there that you can download that work pretty good. One that I know of is entropy search, which I use on my site. the only downfall is that it reads meta tags, not MySQL, and is written in cgi... Anyways, you can even build your own using google api keys. you can get one at api.google.com.
Reply With Quote
  #3 (permalink)  
Old 01-01-06, 12:38 PM
eq1987 eq1987 is offline
Wannabe Coder
 
Join Date: Dec 2003
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
This is easily done.

connect to MySQL and open the database
PHP Code:

$MySQL_Connect mysql_connect("localhost""user""password") or die(mysql_error());

mysql_select_db("DatabaseName"$MySQL_Connect) or die(mysql_error()); 
Next, you need to SELECT all the rows that meet your criteria
PHP Code:

$KeyWords addslashes(htmlentities($_GET['Keywords'])); // assuming you have a keyword search form, using method="GET"

$SQL mysql_query("SELECT * FROM tblLinks WHERE Description LIKE '%$KeyWords%' ORDER BY Title ASC LIMIT 15") or die(mysql_error());
while(
$SQLRes mysql_fetch_array($SQL)) {
 
$DisplayVar .= '<a href="'.$SQLRes['URL'].'">'.$SQLRes['Title'].'</a><br>';

then echo the $DisplayVar where you want the results to display
PHP Code:

echo $DisplayVar
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
In need of a simple PHP image gallery script.. 6pt7 Script Requests 2 08-30-09 09:21 AM
CNET Shopping XML Feed to PHP Parsing Script Needed angmi90 Script Requests 0 04-22-05 03:28 PM
PHP Real Estate script Needed ---> $$$ Brainstorm Job Offers & Assistance 4 11-19-04 05:49 AM
I need a simple PHP script . . . willing to pay kacyl Script Requests 4 02-10-04 05:30 PM
PHP script needed for an application gicone32 Script Requests 0 10-02-03 12:44 PM


All times are GMT -5. The time now is 06:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.