Lost Password?


  #1 (permalink)  
Old 12-30-2006, 10:09 AM
Jaan's Avatar   
Jaan Jaan is offline
Mod
 
Join Date: Dec 2006
Location: Estonia
Age: 17
Posts: 930
Last Blog:
AdStar Ad Control Pa...
Rep Power: 16
Jaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the roughJaan is a jewel in the rough
Send a message via MSN to Jaan
Default Simple MySQL Database Search

Hello

Here i will show how to make a simple searchengine. First we must make a form:

search.html

HTML Code:
<form action="search.php" method="post">
<input type="text" name="find" size="30" /><br />
<input type="submit" value="Search" />
</form>
Now we must make this php part.

search.php

PHP Code:
<?php
// First connect to database
$host "localhost";
$dbuser "username";
$dbpass "password";
$db "database";

$con mysql_connect($host$dbuser$dbpass);
if(!
$con){
die(
mysql_error());
}

$select mysql_select_db($db$con);
if(!
$select){
die(
mysql_error());
}

// Now collect all info into [b]$item[/b] variable

$item $_REQUEST['find'];

// This will take all info from database where row [i]tutorial[/i] is $item and collects it into [b]$data[/b] variable

$data mysql_query("SELECT * FROM tutorials WHERE tutorial LIKE '%$item%'");

// This creates a loop which will repeat itself until there are no more rows to select from the database. We getting the field names and storing them in the $row variable. This makes it easier to echo each field.

while($row mysql_fetch_array($data)){
echo 
$row['date']. "<br>";
echo 
$row['id']. "<br>";
}

?>
__________________


Cheap & Professional Web Design | Need help? Send a PM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 01-01-2007, 11:15 AM
xtraze xtraze is offline
Programming God
 
Join Date: Dec 2006
Location: Sri lanka
Posts: 921
Rep Power: 0
xtraze is on a distinguished road
Send a message via MSN to xtraze Send a message via Skype™ to xtraze
Default

Nice but I use Google custom Search Engine as Google is better than me and I really like Google stuff.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL CheatSheet - A must for MySQL Users reachpradeep Database & Database Programming 1 03-03-2007 04:05 PM
Ban IPs with MySQL database Jaan PHP Tutorials 0 01-15-2007 03:13 PM
Shell: MySQL Database Backup Jordan Tutorials 0 08-15-2006 04:18 PM
How do I make a Mysql Database Connection Chan PHP Forum 1 07-17-2006 12:00 PM
MySQL Resources dirkfirst Database & Database Programming 1 05-25-2006 03:31 AM


All times are GMT -5. The time now is 06:07 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads