Welcome to WebmasterWorld Guest from 54.144.80.75

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Auto Complete

     
3:15 am on Jun 18, 2012 (gmt 0)

New User

joined:June 15, 2012
posts:6
votes: 0


Can u please help me to have some codes for "auto-complete" in text-box that gets the data from the database


Tnx :)
3:28 am on June 18, 2012 (gmt 0)

Senior Member from FR 

WebmasterWorld Senior Member leosghost is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Feb 15, 2004
posts:6717
votes: 230


search "javascript auto-complete"
4:53 am on June 18, 2012 (gmt 0)

New User

joined:June 15, 2012
posts: 6
votes: 0


Is there a code for this in PHP. I need to write it in PHP form :)
3:54 pm on June 18, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


You can put Javascript into PHP files, but auto complete is a function of the browser, not server side programming, and the only access to the browser itself is via client side scripting - as said, Javascript (or VBscript.)
12:52 pm on June 20, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 21, 2002
posts: 1541
votes: 0


<html>
<head>
<script type="text/javascript">
function findmatch() {
if (window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('results').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET', 'search.inc.php?search_text='+document.search.search_text.value, true);
xmlhttp.send();
}
</head>
<body>
<form id="search" name="search">
Type a name:<br>
<input type="text" name="search_text" onkeyup="findmatch();">
</form>
<div id="results"></div>
</body>
</html>


****************search-inc.php**************

<?php

if (isset($_GET['search_text'])) {
echo $search_text = $_GET['search_text'];
}

if (!empty($search_text)) {

if (mysql_connect('localhost','root','')) {
id (mysql_connect_db('a_database')) {

$query = "SELECT `firstname` FROM `names` WHERE `name` LIKE '".mysql_real_escape_string($search_test)."%'";
$query_run = mysql_query($query);

while ($query_row = mysql_fetch_assoc($query_run))
echo $name = $query_row['name'].'<br>';

}
}
}

?>
5:53 pm on June 27, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:May 4, 2004
posts: 394
votes: 0


Here's a start [jqueryui.com...]
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members