954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Search Bar For My Website Using Php/Mysql That Would Search All Items In My Site

Hello ,
I am a new user of this site and also new to web development.Recently while developing my site on tourism by php/mysql i thought of placing a search bar at the top of my website where users can search topics and results would be provided according to the keywords entered by them.
Is there any way to search all the tables of my database and provide the results to users.
Any idea regarding this would be of great help.

I have created a search bar as under





jazz.viper
Newbie Poster
5 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Hey there,

That code will not work at all! That will just create a little text box with a submit button and will not do anything when trying to search.

I would suggest you go to this site right here:

http://expressionengine.com/docs/modules/search/simple.html

This site tells you how to make a simple search engine for your site.

Have fun.

untitledking
Light Poster
36 posts since Mar 2010
Reputation Points: 8
Solved Threads: 2
 

Hello
untitledking,

I visited the link you provided.But can't figure out how to make it work in my site.Firstly i couldn't understand the following highlighted lines
-----------------------------------------------------------------------------------------
{exp:search:simple_form weblog="news"}
Search:

Advanced Search

{/exp:search:simple_form}
-----------------------------------------------------------------------------------------
Again on which page will the results be displayed???
If u can please explain me in detail it would be of great help.

jazz.viper
Newbie Poster
5 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Use REG EXP for search
Search.html page below

<form action="show.php" method="post">

<input type="text" value="Enter Site ID" name="a" class="textfield_effect" maxlength="30" onfocus="this.value=''">
</td>
</tr>
<tr>
            <td align="center" style="font-family:Calibri">
<input type="submit"  value=""/>
</form>

and show.php below

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$a= $_POST["a"]; <strong>//get value from search.html</strong>
mysql_select_db("onm", $con);

$result = mysql_query("SELECT * FROM info
WHERE SiteId REGEXP '$a'");

while($row = mysql_fetch_array($result))
  {
  echo "<table  align=center class=lims>";
  echo "<tr>";
  echo "<th bgcolor=#5D9BCC >SiteID</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['SiteId'] . "</td>";
  
  
  echo "<tr>";
			
			
			
  echo "<th bgcolor=#5D9BCC>Alias</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['Alias'] . "</td>";
  
    echo "</tr>";
	
	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>Code</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['Code'] . "</td>";
    echo "</tr>";
	
	
	 echo "<tr>";
  echo "<th bgcolor=#5D9BCC>Region</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['Region'] . "</td>";
    echo "</tr>";
	
	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>City</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['City'] . "</td>";
    echo "</tr>";
	

	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>GF-RT Status</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['GreenFieldRoofTop'] . "</td>";
    echo "</tr>";
	
	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>Indoor OutdoorStatus</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['IndoorOutdoor'] . "</td>";
    echo "</tr>";
	
	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>HODate</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['HODate'] . "</td>";
    echo "</tr>";
	
	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>Host</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['Host'] . "</td>";
    echo "</tr>";
	
	echo "<tr>";
  echo "<th bgcolor=#5D9BCC>Guest</th>";
  echo "<td bgcolor=#FEE9A9>" . $row['Guest'] . "</td>";
    echo "</tr>";
	
	

	 
	  $b =$row['SiteId']; 
  }
echo "</table>";


mysql_close($con);

?>
furqan219
Junior Poster in Training
89 posts since Jun 2009
Reputation Points: 2
Solved Threads: 4
 

Can you please explain me line 11 & 12 of search.php

jazz.viper
Newbie Poster
5 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: