Witam mój problem jest taki potrzebuje wypełnić formularz danymi z bazy dajmy na przykład:
struktura bazy :
ID | Imie | Nazwisko | Adres
i mam stronke w ktrórej wpisuje powiedzmy Nazwisko i w tym moemncie ukazuje mi sie autosugestja wybieram interesujacy mnie rekord i reszta pol automatycznie jest uzupelniona tymi danymi.
W internecie znalazlem taki komponecik : " Auso możemy w szybki i prosty sposób stworzyć wyszukiwanie z podpowiedziami. Skrypt do działania wymaga PHP i bazy danych. Zarówno wygląd jak i sposób pobierania danych z bazy można bardzo łatwo zmienić "
Demo:
http://oslund.ca/demos/ausu/przerobiłem delikatnie ten skypcik / kod że wyświetla imie i nazwisko....ale nie potrafie tego przerobic tak zeby mi uzupełnił resztę pol danymi.
moj plik DATA:
<?php
/*
* AUSU jQuery-Ajax Autosuggest v1.0
* Demo of a simple server-side request handler
* Note: This is a very cumbersome code and should only be used as an example
*/
# Establish DB Connection
# Assign local variables
$id = @$_POST['id']; // The id of the input that submitted the request.
$data = @$_POST['data']; // The value of the textbox.
if ($id && $data)
{
if ($id=='countries')
{
$query = "SELECT `Id`,`Imie`, `Nazwisko`
FROM `kontrahenci`
WHERE `Nazwisko` LIKE '%$data%'
LIMIT 5";
{
$toReturn = $row['Nazwisko'];
$dataList[] = '<li id="' .$row['Id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>'; }
{
$dataOutput = join("\r\n", $dataList); }
else
{
echo '<li><a href="#">Brak rekordow</a></li>'; }
}
elseif ($id=='categories')
{
$query = "SELECT Id,Imie, Nazwisko
FROM kontrahenci
WHERE Nazwisko LIKE '%$data%'
LIMIT 5";
{
$toReturn = $row['Nazwisko']." ".$row['Imie'];
$dataList[] = '<li id="' .$row['Id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
}
{
$dataOutput = join("\r\n", $dataList); }
else
{
echo '<li><a href="#">Brak rekordów</a></li>'; }
}
}
else
{
}
?>
i plik index :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AUSU DEMO | jQuery-Ajax Auto Suggest Plugin</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<style>
div {margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size:12px; }
.ausu-suggest {width: 280px;}
#wrapper {margin-left: auto; position: relative; margin-right: auto; margin-top:75px ;width: 600px;}
h3 {font-size: 11px; text-align: center;}
span {font-size: 11px; font-weight: bold}
a
:link {color
: #F06;text-decoration: none;} a:visited {text-decoration: none;color: #F06;}
a:hover {text-decoration: underline;color: #09F;}
a:active {text-decoration: none;color: #09F;}
.ausu-suggest1 {width: 280px;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.ausu-autosuggest.min.js"></script>
<script>
$(document).ready(function() {
$.fn.autosugguest({
className: 'ausu-suggest',
methodType: 'POST',
minChars: 2,
rtnIDs: true,
dataFile: 'data.php'
});
});
</script>
</head>
<body>
<div id="wrapper">
<form action="index.php" method="get">
<div class="ausu-suggest">
<input type="text" size="25" value="" name="categories" id="categories" autocomplete="off" />
<input type="text" size="4" value="" name="categoriesIDs" id="categoriesIDs" autocomplete="off" disabled="disabled" />
<input type="text" size="24" value="" name="categoriesID" id="categoriesID" autocomplete="off" disabled="disabled" />
<input name="go" type="submit" value="go" style="width:1px;height:1px" />
</div>
</form>
<div style="clear:both"></div>
</div>
</body>
</html>
ktoś ma może jakiś pomysł ? lub jakieś inne rozwiązanie ?