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:

  1. <?php
  2. /*
  3.  * AUSU jQuery-Ajax Autosuggest v1.0
  4.  * Demo of a simple server-side request handler
  5.  * Note: This is a very cumbersome code and should only be used as an example
  6.  */
  7.  
  8. # Establish DB Connection
  9. $con = mysql_connect("localhost","xx_fa","fak");
  10. if (!$con){ die('Could not connect: ' . mysql_error()); }
  11. mysql_select_db("morawiec_fa", $con);
  12.  
  13. # Assign local variables
  14. $id = @$_POST['id']; // The id of the input that submitted the request.
  15.  
  16. $data = @$_POST['data']; // The value of the textbox.
  17.  
  18. if ($id && $data)
  19. {
  20. if ($id=='countries')
  21. {
  22. $query = "SELECT `Id`,`Imie`, `Nazwisko`
  23. FROM `kontrahenci`
  24. WHERE `Nazwisko` LIKE '%$data%'
  25. LIMIT 5";
  26.  
  27. $result = mysql_query($query);
  28.  
  29. $dataList = array();
  30.  
  31. while ($row = mysql_fetch_array($result))
  32. {
  33. $toReturn = $row['Nazwisko'];
  34. $dataList[] = '<li id="' .$row['Id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
  35. }
  36.  
  37. if (count($dataList)>=1)
  38. {
  39. $dataOutput = join("\r\n", $dataList);
  40. echo $dataOutput;
  41. }
  42. else
  43. {
  44. echo '<li><a href="#">Brak rekordow</a></li>';
  45. }
  46. }
  47. elseif ($id=='categories')
  48. {
  49. $query = "SELECT Id,Imie, Nazwisko
  50. FROM kontrahenci
  51. WHERE Nazwisko LIKE '%$data%'
  52. LIMIT 5";
  53.  
  54. $result = mysql_query($query);
  55.  
  56. $dataList = array();
  57.  
  58. while ($row = mysql_fetch_array($result))
  59. {
  60. $toReturn = $row['Nazwisko']." ".$row['Imie'];
  61. $dataList[] = '<li id="' .$row['Id'] . '"><a href="#">' . htmlentities($toReturn) . '</a></li>';
  62.  
  63. }
  64.  
  65. if (count($dataList)>=1)
  66. {
  67. $dataOutput = join("\r\n", $dataList);
  68. echo $dataOutput;
  69. }
  70. else
  71. {
  72. echo '<li><a href="#">Brak rekordów</a></li>';
  73. }
  74. }
  75.  
  76. }
  77. else
  78. {
  79. echo 'Bład zapytania!';
  80. }
  81. ?>


i plik index :
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>AUSU DEMO | jQuery-Ajax Auto Suggest Plugin</title>
  7. <link rel="stylesheet" type="text/css" href="css/style.css" />
  8. <style>
  9. div {margin: 10px; font-family: Arial, Helvetica, sans-serif; font-size:12px; }
  10. .ausu-suggest {width: 280px;}
  11. #wrapper {margin-left: auto; position: relative; margin-right: auto; margin-top:75px ;width: 600px;}
  12. h3 {font-size: 11px; text-align: center;}
  13. span {font-size: 11px; font-weight: bold}
  14.  
  15. a:link {color: #F06;text-decoration: none;}
  16. a:visited {text-decoration: none;color: #F06;}
  17. a:hover {text-decoration: underline;color: #09F;}
  18. a:active {text-decoration: none;color: #09F;}
  19. .ausu-suggest1 {width: 280px;}
  20. </style>
  21. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
  22. <script type="text/javascript" src="js/jquery.ausu-autosuggest.min.js"></script>
  23. <script>
  24. $(document).ready(function() {
  25. $.fn.autosugguest({
  26. className: 'ausu-suggest',
  27. methodType: 'POST',
  28. minChars: 2,
  29. rtnIDs: true,
  30. dataFile: 'data.php'
  31. });
  32. });
  33. </script>
  34. </head>
  35. <body>
  36.  
  37. <div id="wrapper">
  38. <form action="index.php" method="get">
  39.  
  40. <div class="ausu-suggest">
  41. <input type="text" size="25" value="" name="categories" id="categories" autocomplete="off" />
  42. <input type="text" size="4" value="" name="categoriesIDs" id="categoriesIDs" autocomplete="off" disabled="disabled" />
  43. <input type="text" size="24" value="" name="categoriesID" id="categoriesID" autocomplete="off" disabled="disabled" />
  44. <input name="go" type="submit" value="go" style="width:1px;height:1px" />
  45.  
  46. </div>
  47. </form>
  48. <div style="clear:both"></div>
  49. </div>
  50. </body>
  51. </html>


ktoś ma może jakiś pomysł ? lub jakieś inne rozwiązanie ?