Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Odczyt z tablicy
Forum PHP.pl > Forum > Przedszkole
Deusx
  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?
tehaha
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. ?>
Deusx
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
tehaha
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);
jaslanin
  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 ?
Deusx
$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
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.