Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-07-2009, 12:48 PM   #1 (permalink)
aldernon's Avatar
 
Junior Techie

Join Date: Feb 2009

Location: Brazil

Posts: 76

aldernon is on a distinguished road

Default I Need A Search Feature

Im working on a site and would like to implament a search bar. Ive been looking around, and all I can seem to find are services you register with, that do all the work for you.

I want a script or something, that is all local to my server and my site. Can anyone suggest good options?

Thank you very much!
aldernon is offline  
Old 03-07-2009, 03:24 PM   #2 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,687

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: I Need A Search Feature

PHP Code:
<?php

// mysql credentials
$host 'localhost';  // mysql server domain
$user 'root';       // mysql username
$pass 'root';       // mysql password
$db   'dbname';     // mysql database name

// connect to mysql
$connect = @mysql_connect ($host,$user,$pass) or die ('error connecting to database!');
$select  = @mysql_select_db ($db,$connect) or die ('error connecting to database!');

if (isset (
$_POST['submit'])) {
    
// if submit is pressed
    // get search keyword from form
    
$search mysql_escape_string ($_POST['search']);

    if (!empty (
$search)) {
        
// perform sql query to find like values in table
        
$sql mysql_query ("SELECT * FROM table WHERE column='%".$search."%'");
        
        if (
mysql_num_rows ($sql) > 0) {
            
// if a match is found
            
while ($row mysql_fetch_array ($sql)) {
                
// echo results
                
echo $row['column'].'<br />';
            }
        } else {
            
// no matches found
            
echo 'No matches for '.$search;
        }
    } else {
        
// empty search keywords
        
echo 'You did not enter a search keyword!';
    }
} else {
    echo 
'<form action="search.php" method="post">
    Search: <input type="text" name="search" /> <input type="submit" name="submit" value="Go" />
    </form>'
;
}

?>
Here is a basic search with PHP.
__________________

Need website help? PM me!
CrazeD is offline  
Old 03-07-2009, 10:06 PM   #3 (permalink)
aldernon's Avatar
 
Junior Techie

Join Date: Feb 2009

Location: Brazil

Posts: 76

aldernon is on a distinguished road

Default Re: I Need A Search Feature

Thank you alot CrazeD. Ive watched a few of you're videos, you really know you're stuff.

Could you help me a little more? I need to create the database, basically start from the beginning. Im very eager to learn this, and catch on fast.

Any help you could send my way would be appreciated. I understand its hard work helping people, if you cant, Its all good.

Thanks for everything,
Sean.
aldernon is offline  
Old 03-08-2009, 01:23 AM   #4 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,687

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: I Need A Search Feature

If you have PHPMyAdmin, then you can follow along on how to create the database, tables, and connect to it in part 1 of my login video tutorial.

You'll just need to make a table with the columns you want, and then adjust that script a little for your own use.

Maybe I'll make a video tutorial for a search.
__________________

Need website help? PM me!
CrazeD is offline  
Old 03-08-2009, 07:40 PM   #5 (permalink)
Spit-wad's Avatar
 
Bake a Pretty Cake!

Join Date: Jun 2008

Location: Madison, WI

Posts: 718

Spit-wad will become famous soon enough

Default Re: I Need A Search Feature

Where are your videos, CrazeD? I've been trying to teach myself some website development stuff lately.
Spit-wad is offline  
Old 03-08-2009, 10:07 PM   #6 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,687

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: I Need A Search Feature

Quote:
Originally Posted by Spit-wad View Post
Where are your videos, CrazeD? I've been trying to teach myself some website development stuff lately.
My PHP Video Tutorials

I only have one tutorial so far. Was gonna see how well it took off as to how many I do. If you have any requests, go ahead and post in that thread.
__________________

Need website help? PM me!
CrazeD is offline  
Old 03-08-2009, 10:17 PM   #7 (permalink)
aldernon's Avatar
 
Junior Techie

Join Date: Feb 2009

Location: Brazil

Posts: 76

aldernon is on a distinguished road

Default Re: I Need A Search Feature

can you do a tutorial based on making a search feature? Maybe add some more functionality perspectives to it. I loved you're videos, but found they kind of left me hanging.

For example, if you're trying to teach someone how to make a search feature, start from the beginning, making the database, then go right to the end, making a forum.

Not for me, but for anyone interested =D
Just a suggestion,
Keep up the good work man.
aldernon is offline  
Old 03-09-2009, 12:22 AM   #8 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,687

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: I Need A Search Feature

A forum is a lot to cover in a video tutorial.

I'll work on the search tutorial though.
__________________

Need website help? PM me!
CrazeD is offline  
Old 03-09-2009, 07:35 AM   #9 (permalink)
aldernon's Avatar
 
Junior Techie

Join Date: Feb 2009

Location: Brazil

Posts: 76

aldernon is on a distinguished road

Default Re: I Need A Search Feature

Forgive me, i suck at spelling hahaha. I meant a FORM not Forum.

Like a simple display of the search results <3 Very basic, no need for design or beauty.

Sorry again.
aldernon is offline  
Old 03-09-2009, 02:19 PM   #10 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,687

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: I Need A Search Feature

Oh, I see.

I'll throw something together tonight maybe.
__________________

Need website help? PM me!
CrazeD is offline  
 
Closed Thread

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista SP1 Windows Media Center TV Pack Makes Search for TV Content Useless Mak213 Windows Operating Systems and Software 3 08-21-2008 10:33 PM
OBSCURE GOOGLE Search Tricks mattew Search Engines & Internet Traffic 5 07-21-2008 01:29 AM
Enterprise Search Tool jigneshjsoni Windows Operating Systems and Software 5 07-17-2008 12:59 AM
Windows Search 4.0 Released Mak213 Windows Operating Systems and Software 0 06-11-2008 11:18 PM
Hackers re-poison Google search results Osiris Virus - Spyware Protection / Detection 0 11-30-2007 12:16 PM