Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Search Bar


  • Please log in to reply
8 replies to this topic

#1 JUICYboy

JUICYboy

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:07:15 PM

Posted 06 May 2011 - 12:52 AM

Search Bar on a website...

I understand Google and other Companies have there cut and paste code.

But I would like to learn how to do my own...


Can someone point me in the right direction of what I need to learn in order to achieve the task....

Thanks.... :inlove:

BC AdBot (Login to Remove)

 


#2 cryptodan

cryptodan

    Bleepin Madman


  • Members
  • 21,868 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Catonsville, Md
  • Local time:11:15 PM

Posted 06 May 2011 - 12:54 AM

What is it exactly do you want to do?

#3 ReviverSoft

ReviverSoft

    Happy to help!


  • Members
  • 1,552 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Somewhere on this planet...
  • Local time:04:15 PM

Posted 06 May 2011 - 09:05 AM

Well, you could start with this little guide.

Few other resources:



http://www.developerfusion.com/article/4389/create-a-site-search-engine-in-aspnet/

http://www.alistapart.com/articles/perl/

http://www.devshed.com/c/a/MySQL/Building-a-Search-Engine-with-MySQL-and-PHP-5/
ReviverSoft - Happy to help!

#4 JUICYboy

JUICYboy
  • Topic Starter

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:07:15 PM

Posted 06 May 2011 - 09:35 AM

I want to learn how a search bar works and how to create my own..... :thumbup2:

#5 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:05:15 PM

Posted 06 May 2011 - 10:11 AM

A search bar is simply an input field tied to a search engine. If you want to search within your own pages, you will have to write a function that does a text search within your own pages. If you want to do an internet search, you will can just feed a query to one of the search engines.

#6 JUICYboy

JUICYboy
  • Topic Starter

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:07:15 PM

Posted 10 May 2011 - 12:58 AM

Thanks for the tutorial its helping me alot :thumbup2:

I have one problem:
mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a1896651/public_html/search.php on line 47

In the Youtube tutorial 4/5 he made a mistake and corrected it I corrected it as well but mine is still showing the warning.
I researched and some forums say its a missing "{" others say something else it has something to do with the following line of code (line 47):"$foundnum = mysql_num_rows($run);"

The link: http://www.mytemplate.uphero.com/

	<?php

	//get data
	
	$button = $_GET['submit'];
	$search = $_GET['search'];
	
	if (!$button)
		echo "You did not submit a keyword";
	else
	{
		if(strlen($search)<=2)
			echo "Search term too short";
		else
		{
			echo "You searched for: <b>$search</b> <hr size='1'>";
			
			//conect to database
			mysql_connect("*****","*******","******");
			mysql_select_db("a1896651_123");
			
			
				
				//exlode search term
				
			$search_exploded = explode(" ",$search);
			foreach($search_exploded as $search_each)
			{
				
			$x++;
			if(x==1)
			   $construct .= "keywords LIKE '%$search_each%'";
		   	else
		   	   $construct .= " OR keywords LIKE '%$search_each%'";

			}		
				
				
				
			
			
			//echo out construct
			
			$construct = "SELECT * FROM searchengine WHERE $construct";
			$run = mysql_query($construct);
			
			$foundnum = mysql_num_rows($run);
			
			if ($foundnum==0)
				echo "No results found";
			
			else
			{
			
				echo "$foundnum results found!<p> ";
				
			}
			
			/*echo $construct;
			die();*/
			
		}
	}


	?>

Edited by groovicus, 10 May 2011 - 07:18 AM.
removed database credentials.


#7 cryptodan

cryptodan

    Bleepin Madman


  • Members
  • 21,868 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Catonsville, Md
  • Local time:11:15 PM

Posted 10 May 2011 - 02:15 AM

Please remove your username's and passwords from your post.

#8 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:05:15 PM

Posted 10 May 2011 - 07:16 AM

I removed your credentials, but you should go ahead and change them since anyone that read your post now has the ability to log into your database.

#9 JUICYboy

JUICYboy
  • Topic Starter

  • Members
  • 537 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Anaheim, Ca
  • Local time:07:15 PM

Posted 10 May 2011 - 09:39 AM

Okay I will change my log in credentials.

I got caught up in trying to fix my issue I forgot when I uploaded my code..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users