Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Odczyt z tablicy, array();
Deusx
post 31.05.2010, 00:33:16
Post #1





Grupa: Zarejestrowani
Postów: 126
Pomógł: 2
Dołączył: 27.08.2006

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


  1. $Count = 0;
  2. $a = 0;
  3. $aUzyteIp = array();
  4. $aNazwa = array();
  5. echo '<center><br><br><table width=400><tr><td class=c colspan=3>Multi konta</td></tr>';
  6. while ( $TheUser = mysql_fetch_array($Last15Mins) ) {
  7.  
  8.  
  9. if (in_array($TheUser['user_lastip'],$aUzyteIp)) {
  10. $status = doquery("SELECT `status` FROM {{table}} WHERE `username` ='".$TheUser['username']."' OR `nick1` ='".$TheUser['username']."'","zglos",true);
  11. if($status['status'] == 0) {
  12. echo '<tr><th>Multi </th>','<th>', $TheUser['user_lastip'] ,'</th><th> ', $TheUser['username'], '</th><th>',$aNazwa[$a] , '</th></tr>' ;//$aNazwa[$a] ma wyswietlic nazwe z tablicy
  13. }
  14. } else {
  15. $aUzyteIp[] = $TheUser['user_lastip'];
  16. $aNazwa[$a] = $TheUser['username']; //tutaj ma zapisac nazwe
  17. }
  18.  
  19.  
  20. $Count++;
  21. $a++;
  22. }
  23. echo '</tr></table>';


Jednak w wyświetlaniu "$aNazwa[$a]" nie ma nic. Bardzo proszę o pomoc, co robię źle?

Ten post edytował Deusx 31.05.2010, 00:34:07
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 5)
tehaha
post 31.05.2010, 00:41:22
Post #2





Grupa: Zarejestrowani
Postów: 1 748
Pomógł: 388
Dołączył: 21.08.2009
Skąd: Gdynia

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


a sprawdzałeś czy dochodzi do przypisania tej wartości?
  1. <?php
  2. $Count = 0;
  3. $a = 0;
  4. $aUzyteIp = array();
  5. $aNazwa = array();
  6. echo '<center><br><br><table width=400><tr><td class=c colspan=3>Multi konta</td></tr>';
  7. while ( $TheUser = mysql_fetch_array($Last15Mins) ) {
  8.  
  9.  
  10. if (in_array($TheUser['user_lastip'],$aUzyteIp)) {
  11. echo "a";
  12. $status = doquery("SELECT `status` FROM {{table}} WHERE `username` ='".$TheUser['username']."' OR `nick1` ='".$TheUser['username']."'","zglos",true);
  13. if($status['status'] == 0) {
  14. echo '<tr><th>Multi </th>','<th>', $TheUser['user_lastip'] ,'</th><th> ', $TheUser['username'], '</th><th>',$aNazwa[$a] , '</th></tr>' ;//$aNazwa[$a] ma wyswietlic nazwe z tablicy
  15. }
  16. } else {
  17. echo "b";
  18. $aUzyteIp[] = $TheUser['user_lastip'];
  19. $aNazwa[$a] = $TheUser['username']; //tutaj ma zapisac nazwe
  20. }
  21.  
  22.  
  23. $Count++;
  24. $a++;
  25. }
  26. echo '</tr></table>';
  27. ?>
Go to the top of the page
+Quote Post
Deusx
post 31.05.2010, 10:32:47
Post #3





Grupa: Zarejestrowani
Postów: 126
Pomógł: 2
Dołączył: 27.08.2006

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


Jeżeli chodzi czy wyświetli echo "b";, tak wyświetla b (xx razy).
echo "a"; również jest wyświetlane, gdy jest spełniony warunek

Nie mam zielonego pojęcia, czemu to nie chce działać sad.gif


Ten post edytował Deusx 31.05.2010, 10:54:12
Go to the top of the page
+Quote Post
tehaha
post 31.05.2010, 10:59:09
Post #4





Grupa: Zarejestrowani
Postów: 1 748
Pomógł: 388
Dołączył: 21.08.2009
Skąd: Gdynia

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


a po co taki zapis, skoro i tak zaczynasz od zera
  1. $aNazwa[$a] = $TheUser['username'];
wyjdzie na to samo jak będzie
  1. $aNazwa[] = $TheUser['username'];
po za tym daj tam
  1. echo $TheUser['username'];
żeby zobaczyć czy przypadkiem nie przypisujesz pustej wartości a na samym końcu po za pętlą daj
  1. print_r($aNazwa);
Go to the top of the page
+Quote Post
jaslanin
post 31.05.2010, 11:01:43
Post #5





Grupa: Zarejestrowani
Postów: 511
Pomógł: 143
Dołączył: 13.03.2010
Skąd: Jasło

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


  1. <?php
  2. $Count = 0;
  3. $a = 0;
  4. $aUzyteIp = array();
  5. $aNazwa = array();
  6. echo '<center><br><br><table width=400><tr><td class=c colspan=3>Multi konta</td></tr>';
  7. while ( $TheUser = mysql_fetch_array($Last15Mins) ) {
  8.  
  9.  
  10. if (in_array($TheUser['user_lastip'],$aUzyteIp)) {
  11. echo "a";
  12. $status = doquery("SELECT `status` FROM {{table}} WHERE `username` ='".$TheUser['username']."' OR `nick1` ='".$TheUser['username']."'","zglos",true);
  13. if($status['status'] == 0) {
  14. echo '<tr><th>Multi </th>','<th>', $TheUser['user_lastip'] ,'</th><th> ', $TheUser['username'], '</th><th>',$aNazwa[$a] , '</th></tr>' ;//$aNazwa[$a] ma wyswietlic nazwe z tablicy
  15. }
  16. } else {
  17. echo "b";
  18. $aUzyteIp[] = $TheUser['user_lastip'];
  19. $aNazwa[$a] = $TheUser['username']; //tutaj ma zapisac nazwe
  20. }
  21.  
  22.  
  23. $Count++;
  24. $a++;
  25. }
  26. echo '</tr></table>';
  27. echo "<pre>";
  28. print_r($aNazwa);
  29. echo "</pre>";
  30.  
  31. ?>


Co Ci wyświetla ?


--------------------
Good luck and happy PHP'ing
Go to the top of the page
+Quote Post
Deusx
post 31.05.2010, 18:40:26
Post #6





Grupa: Zarejestrowani
Postów: 126
Pomógł: 2
Dołączył: 27.08.2006

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


$a - 1 musiało być - rozwiązanie problemu, jednak nie do końca.


Jak jest

  1. if (in_array($TheUser['user_lastip'],$aUzyteIp)) {


I teraz chodzi mi o to, żeby pokazało mi wszystkie:
$aNazwa mające to samo IP ($aUzyteIp)

P.S

Array
(
[0] => gawron32
[1] => tygrys55
[2] => Vendetta
[3] => berkas97
[4] => jerzy
[5] => kroki
[6] => merlin456
[7] => zbyszek1970
[8] => pulas22222
....
)

Działa poprawnie, tylko problem polegał na ty, że już chciałem wyświetlić $a, które było do przodu smile.gif

Bardzo proszę o pomoc

Ten post edytował Deusx 31.05.2010, 11:11:49
Go to the top of the page
+Quote Post

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 Wersja Lo-Fi Aktualny czas: 14.06.2025 - 11:16