advance search script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saiphpuser
Forum Newbie
Posts: 6
Joined: Mon Apr 23, 2012 12:53 pm

advance search script

Post by saiphpuser »

please tell advance search functionality using ajax in php .
jdavid
Forum Newbie
Posts: 1
Joined: Wed May 02, 2012 11:49 pm

Re: advance search script

Post by jdavid »

Hi,
For advance search functionality using Ajax in PHP do as per the following instructions

Step 1: main page
This page contains the search engine input field, and show the search results into the layer <div id="search-result">
Add a link to javascript function inside the <head> tag

<script language="javascript" src="ajax_framework.js"></script>

..and copy this code into the <body> tag:

<h2>Ajax Search Engine</h2>

<form id="searchForm" name="searchForm" method="post" action="javascript:insertTask();">
<div class="searchInput">
<input name="searchq" type="text" id="searchq" size="30" onkeyup="javascript:searchNameq()"/>
<input type="button" name="submitSearch" id="submitSearch" value="Search" onclick="javascript:searchNameq()"/>
</div>
</form>

<h3>Search Results</h3>
<div id="msg">Type something into the input field</div>
<div id="search-result"></div>

Step 3: search into database
This code searching for the name in input into the database. Take a look here to see dbconnection.php code:
{
include('dbconnection.php');
$searchq = $_GET['searchq'];
$getName_sql = 'SELECT * FROM USER
WHERE name LIKE "%' . $searchq .'%"
$getName = mysql_query($getTask_sql);
$total = mysql_num_rows(getTask);

while ($row = mysql_fetch_array($getName)) {
echo $row.name . '<br/>';
}
Post Reply