|  | |
03-07-2009, 12:48 PM
|
#1 (permalink)
|
Junior Techie Join Date: Feb 2009 Location: Brazil Posts: 76
| 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! |
| |
03-07-2009, 03:24 PM
|
#2 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,687
| 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! |
| |
03-07-2009, 10:06 PM
|
#3 (permalink)
|
Junior Techie Join Date: Feb 2009 Location: Brazil Posts: 76
| 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. |
| |
03-08-2009, 01:23 AM
|
#4 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,687
| 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! |
| |
03-08-2009, 07:40 PM
|
#5 (permalink)
|
Bake a Pretty Cake! Join Date: Jun 2008 Location: Madison, WI Posts: 718
| Re: I Need A Search Feature Where are your videos, CrazeD? I've been trying to teach myself some website development stuff lately. |
| |
03-08-2009, 10:07 PM
|
#6 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,687
| Re: I Need A Search Feature Quote:
Originally Posted by Spit-wad 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! |
| |
03-08-2009, 10:17 PM
|
#7 (permalink)
|
Junior Techie Join Date: Feb 2009 Location: Brazil Posts: 76
| 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. |
| |
03-09-2009, 12:22 AM
|
#8 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,687
| 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! |
| |
03-09-2009, 07:35 AM
|
#9 (permalink)
|
Junior Techie Join Date: Feb 2009 Location: Brazil Posts: 76
| 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. |
| |
03-09-2009, 02:19 PM
|
#10 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,687
| Re: I Need A Search Feature Oh, I see.
I'll throw something together tonight maybe.
__________________ Need website help? PM me! |
| |  | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |