Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Problem z wyswietlaniem autosugesti
karolo_k
post
Post #1





Grupa: Zarejestrowani
Postów: 84
Pomógł: 5
Dołączył: 12.01.2010

Ostrzeżenie: (0%)
-----


Witam, długo czasu szukałem takiego skryptu aż w końcu znalazłem. Jest to autosugestia mniej wiecej taka jaką mamy teraz w googlach.
Chce ten skrypt wykorzystać do podpowiadań adresów IP i emaili w moim panelu. Jadnak mam jeden problem bo poprzerobieniu skryptu na moje potrzeby pojawił się jakiś błąd z którym nie mogę sobie sam porawdzić.
Oto kod :
  1. <?php
  2.  
  3.  
  4. $db = mysql_connect('localhost', 'root' ,'');
  5. mysql_select_db('kraje');
  6.  
  7.  
  8.  
  9.  
  10. if(!$db) {
  11.  
  12. echo 'Could not connect to the database.';
  13. } else {
  14.  
  15. if(isset($_POST['queryString'])) {
  16. $abc = $_POST['queryString'];
  17. $queryString = mysql_real_escape_string($abc);
  18.  
  19. if(strlen($queryString) >0) {
  20.  
  21. $query = mysql_query("SELECT country FROM countries WHERE country LIKE '$queryString%' LIMIT 10");
  22. if($query) {
  23. echo '<ul>';
  24.  
  25. while ($result = $query ->fetch_object()) {
  26. echo '<li onClick="fill(\''.addslashes($result->country).'\');">'.$result->country.'</li>';
  27. }
  28. echo '</ul>';
  29.  
  30. } else {
  31. echo 'OOPS we had a problem :(';
  32. }
  33. } else {
  34. // do nothing
  35. }
  36. } else {
  37. echo 'There should be no direct access to this script!';
  38. }
  39. }
  40. ?>

A tutaj jest oryginalny kod pliku:
  1. <?php
  2. $db = mysql('localhost', 'root' ,'', 'kraje');
  3.  
  4. if(!$db) {
  5.  
  6. echo 'Could not connect to the database.';
  7. } else {
  8.  
  9. if(isset($_POST['queryString'])) {
  10. $queryString = $db->real_escape_string($_POST['queryString']);
  11.  
  12. if(strlen($queryString) >0) {
  13.  
  14. $query = $db->query("SELECT country FROM countries WHERE country LIKE '$queryString%' LIMIT 10");
  15. if($query) {
  16. echo '<ul>';
  17. while ($result = $query ->fetch_object()) {
  18. echo '<li onClick="fill(\''.addslashes($result->country).'\');">'.$result->country.'</li>';
  19. }
  20. echo '</ul>';
  21.  
  22. } else {
  23. echo 'OOPS we had a problem :(';
  24. }
  25. } else {
  26. // do nothing
  27. }
  28. } else {
  29. echo 'There should be no direct access to this script!';
  30. }
  31. }
  32. ?>

Mój problem jest takiej natury:
http://imageshack.us/photo/my-images/37/problemmm.png/
Bardzo proszę o pomoc.
Go to the top of the page
+Quote Post

Posty w temacie
- karolo_k   [MySQL][PHP]Problem z wyswietlaniem autosugesti   11.02.2012, 10:24:50
- - CuteOne   while ($result = $query ->fetch_objec...   11.02.2012, 10:53:49
- - karolo_k   Rozwiązało to tylko część problemu. Teraz już list...   11.02.2012, 11:00:27
- - Gość   test test   11.02.2012, 21:40:18


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 19:26