Problem polega na tym, że jak już wyświetla klientów w <option> to ich id są takie same - a powinny mieć swoje id które są pobierane z bazy.

Mam oto taki kod:

  1. /* Funkcje */
  2.  
  3. function rekord($name)
  4. {
  5. $name=strtolower($name);
  6. if(isset($this->row->$name))
  7. return $this->row->$name;
  8. else
  9. return '';
  10. }
  11.  
  12.  
  13. function Dalej()
  14. {
  15. return $this->Wiersz = ($this->row = pg_fetch_object($this->queryresult));
  16. }
  17.  
  18. function Wiersz()
  19. {
  20. return $this->Wiersz;
  21. }
  22.  
  23. function Otworz()
  24. {
  25. $this->lastError ='';
  26. $this->queryresult = pg_query($this->connection, $this->sql);
  27.  
  28.  
  29. $this->lastError = pg_last_error($this->connection);
  30. if ($this->queryresult) {
  31. $this->Wiersz = ($this->row = pg_fetch_object($this->queryresult));
  32. }
  33.  
  34.  
  35. /* Część główna */
  36.  
  37. $zap->sql = 'select * from produkty';
  38. $zap->Otworz();
  39.  
  40.  
  41.  
  42. $klienci = new Query();
  43. $klienci->sql = "select * from klienci";
  44.  
  45. $klienci->Otworz();
  46.  
  47. // wyświetlenie produktów
  48. while ($zap->Wiersz) {
  49.  
  50. // wyświetlenie klientów
  51. while($klienci->Wiersz) {
  52. $option .= '<option value=\''.$users->rekord('id').'\' onclick="ob.saveKlient(this, \''.$zap->rekorde('prod_id').'\');" >'.$klienci->rekord('nazwa').'</option>';
  53. $users->Dalej();
  54.  
  55. // wyświetlenie listy rozwijanej produktów z id klienta i z id produktu, które będą zapisane do bazy
  56. $list = '<p><select id="klient_id">'.$option.'</select></p>';
  57.  
  58. echo $list;
  59.  
  60. }
  61. }