Mam coś takiego:

  1. <?php
  2. function add_visit($profile, $user) {
  3.  
  4. $this->user__i = $user;
  5.  
  6. $this->visitors = $this->row('SELECT `visitors` FROM `users` WHERE `id` = "'.$profile.'"');
  7.  
  8. $this->visitors = unserialize($this->visitors['visitors']);
  9.  
  10. $this->new_id = count($this->visitors);
  11.  
  12. $i2 = 0;
  13.  
  14. for($i=0;$i<$this->new_id;$i++) {
  15.  
  16. if($this->user__i != $this->visitors[$i]) {
  17.  
  18.  
  19. $i2++;
  20. }
  21.  
  22.  
  23. } 
  24.  
  25. if($i2 == $this->new_id) {
  26.  
  27.  
  28. $this->visitors[] = $this->user__i;
  29.  
  30. $this->new_visitors = addslashes(serialize($this->visitors));
  31.  
  32. mysql_query('UPDATE `users` SET `visitors` = "'.$this->new_visitors.'" WHERE `id` = "'.$profile.'"') or die(mysql_error());
  33.  
  34.  
  35. }
  36. }
  37. ?>


Wszystko działa ok. (Kod trochę sieczka biggrin.gif)

Chciałbym coś trochę innego . tzn. max 10 elementów.

Jeśli osiągnie liczbę 10 elementów, to wszystkie elementy -1 (indeks.) i pozycja 1 w indeksie ma zostać usunięta. A na pozycję 10 ma się pojawić nowy element tongue.gif

Nie wiem czy jasno napisałem ;P