homepage Welcome to WebmasterWorld Guest from 54.161.247.22
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Auto Complete
NoobLike




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

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


Tnx :)

 

Leosghost




msg:4466600
 3:28 am on Jun 18, 2012 (gmt 0)

search "javascript auto-complete"

NoobLike




msg:4466614
 4:53 am on Jun 18, 2012 (gmt 0)

Is there a code for this in PHP. I need to write it in PHP form :)

rocknbil




msg:4466755
 3:54 pm on Jun 18, 2012 (gmt 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.)

whatson




msg:4467601
 12:52 pm on Jun 20, 2012 (gmt 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>';

}
}
}

?>

stef25




msg:4470190
 5:53 pm on Jun 27, 2012 (gmt 0)

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved