To strona na ktorej jest wyszukiwarka:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" charset="UTF-8" src="js/bsn.AutoSuggest_c_2.0.js"></script> <link rel="stylesheet" href="css/autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" /> </head> <body> <form name="form1" method="post"> <input id="testinput" name="znajdz" type="text" class="input_brazowy" size="14"></td> <img src="../gfx/space.gif" width="6" height="10" border="0"></td> <input name="stan" type=submit value="szukaj"> </td> </form> <table width="760" border="1" align="center" cellpadding="0" cellspacing="0"> <TR> <td width="6%">ID</td> <td width="18%">Nazwa_polska_gatunku</td> <td width="18%">Nazwa_lacinska_gatunku</td> <td width="18%">Status_ochronny_konwencja</td> <td width="18%">Status_ochronny_ue</td> <td width="18%">Gatunek_lacinska</td> <td width="18%">Gatunek_polska</td> <td width="18%">Rodzaj_lacinska</td> <td width="18%">Rodzaj_polska</td> <td width="18%">Rodzina_lacinska</td> <td width="18%">Rodzina_polska</td> <td width="18%">Rzad_lacinska</td> <td width="18%">Rzad_polska</td> <td width="18%">Gromada_lacinska</td> <td width="18%">Gromada_polska</td> <td width="18%">Typ_lacinska</td> <td width="18%">Typ_polska</td> <td width="18%">Krolestwo_lacinska</td> <td width="18%">Krolestwo_polska</td> <td width="18%">Link_archive</td> <td width="18%">Zdjecie</td> <td width="30%">Komentarz</td> <td width="18%">Opis</td> <td width="18%">Podpis_pod_zdjeciem</td> <td width="18%">synonimy</td> <td width="18%">mapa</td> </TR> <?php if($stan=='szukaj') { $zapytanie = "SELECT * FROM `UE` WHERE `Nazwa_polska_gatunku` LIKE '%$znajdz%' or `Nazwa_lacinska_gatunku` LIKE '%$znajdz%' or `test1` LIKE '%$znajdz%'"; } } ?> <script type="text/javascript" charset="utf-8"> var options = { script:"test.php?json=true&", varname:"input", json:true, callback: function (obj) { document.getElementById('testid').value = obj.id; } }; var as_json = new AutoSuggest('testinput', options); var options_xml = { script:"test.php?", varname:"input" }; var as_xml = new AutoSuggest('testinput_xml', options_xml); </script> </body> </html>
To jest kod pliku test.php wyswietlajacego podpowiedzi
<?php /* note: this is just a static test version using a hard-coded countries array. normally you would be populating the array out of a database the returned xml has the following structure <results> <rs>foo</rs> <rs>bar</rs> </results> */ "Czubacz he³miasty", "Å»urawie", "Dropie", "Koroñce", "Papugowe", "Ary niebieskie", "Meksykanki", "Loreczki", "Turaki", "Sowy", "Kolibry", "DzioboroÅ¥ce", "Skalikurki", "Cudowronki", "Pude³eczniki", "Kaczugi", "Terapeny, (amerykañskie) Å¥ó³wie pude³kowe, terapeny", "Å»ó³wie l±dowe", "Å»ó³wie morskie", "Å»ó³wiaki w±skog³owe", "Å»ó³wiaki olbrzymie", "Terekaj", "Krokodylowate", "Tuatary; Hatterie", "Biczogony", "Kameleony Å¥yworodne", "Kameleony Å¥yworodne", "Legwany fidÅ¥yjskie", "Legwany l±dowe z Galapagos", "Legwany nosorogie", "Legwany; Iguana", "Szyszkowce", "Teju kajmanowy", "Teju", "Helodermy", "Warany", "Pytony norowe", "Pytony", "Boa", "Ropuchy Å¥yworodne", "Drzewo³azy", "Epifito³az", "LiÅ›cioÅ‚azy", "Mantelle", "Å»aby gÄ™borodne", "Salamandry olbrzymie", "PÅ‚awikoniki", "Latimerie", "Organeczniki", "Ä™", "ZÅ»aby gÄ™borodne", "Z¯Å»aby gÄ™borodne" ); "North Yorkshire", "Nottinghamshire" ); if ($len) { for ($i=0;$i<count($aUsers);$i++) { // had to use utf_decode, here // not necessary if the results are coming from mysql // $aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) ); //if (stripos(utf8_decode($aUsers[$i]), $input) !== false) // $aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) ); } } { for ($i=0;$i<count($aResults);$i++) { $arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"value\": \"".$aResults[$i]['value']."\", \"info\": \"\"}"; } } else { for ($i=0;$i<count($aResults);$i++) { echo "<rs id=\"".$aResults[$i]['id']."\" info=\"".$aResults[$i]['info']."\">".$aResults[$i]['value']."</rs>"; } } ?>
Nie wiem jak sie zabraæ za rozwi±zanie tego problem, nie wiem dlaczego akurat z pierwsza polska listera nie dzia³a