Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> zczytanie danych do tablicy
piczu
post 6.08.2005, 23:39:10
Post #1





Grupa: Zarejestrowani
Postów: 182
Pomógł: 0
Dołączył: 4.01.2005
Skąd: piczu.info

Ostrzeżenie: (10%)
X----


mam tavlice z danymu :
Kod
home_club_id | away_club_id | home_goals | away_goals

sa to mecze ligowe
chce je podliczyc aby stworzyc tabele ale mam rozne problemy.
chcialbym strorzyc tablice $tablica['club_id'] = ('home_goals_plus','home_goals_minus', itd.)
ale id klubow mam nie ciagłe wiec mialbym problem z przejsciem do nastepnego elementu. juz ciezko mi sie mysli, poradzcie cos.


--------------------
pozdrawiam :)
Go to the top of the page
+Quote Post
strife
post 7.08.2005, 02:41:04
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 605
Pomógł: 96
Dołączył: 22.10.2004
Skąd: UK

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


Jeśli dobrze zrozumiałem to nie chcesz aby tablica Ci się nadpisywała... więc zrób:
  1. <?php
  2.  
  3. // ... 
  4. $tablica['club_id'][] = ('home_goals_plus','home_goals_minus');
  5. // ...
  6.  
  7. ?>

questionmark.gif?


--------------------
Go to the top of the page
+Quote Post
piczu
post 7.08.2005, 13:16:52
Post #3





Grupa: Zarejestrowani
Postów: 182
Pomógł: 0
Dołączył: 4.01.2005
Skąd: piczu.info

Ostrzeżenie: (10%)
X----


oto caly moj kod:
  1. <?php
  2. $query='SELECT * FROM leagues';
  3. $_SESSION['db']->query($query);
  4. while ($leagues = $_SESSION['db']->fetchArray()) {
  5. $table[$leagues['home_club_id']][&#092;"home_goals_plus\"] += $leagues['home_goals'];
  6. $table[$leagues['home_club_id']][&#092;"home_goals_minus\"] += $leagues['away_goals'];
  7. $table[$leagues['home_club_id']][&#092;"home_matches\"] ++;
  8. $table[$leagues['away_club_id']][&#092;"away_goals_plus\"] += $leagues['away_goals'];
  9. $table[$leagues['away_club_id']][&#092;"away_goals_minus\"] += $leagues['home_goals'];
  10. $table[$leagues['away_club_id']][&#092;"away_matches\"] ++;
  11. if ($leagues['away_goals']>$leagues['home_goals']) {
  12. $table[$leagues['away_club_id']][&#092;"away_wins\"] ++;
  13. $table[$leagues['away_club_id']][&#092;"away_pts\"] += 3;
  14. $table[$leagues['home_club_id']][&#092;"home_loses\"] ++;
  15. } elseif ($leagues['away_goals']<$leagues['home_goals']) {
  16. $table[$leagues['home_club_id']][&#092;"home_wins\"] ++;
  17. $table[$leagues['home_club_id']][&#092;"home_pts\"] += 3;
  18. $table[$leagues['away_club_id']][&#092;"away_loses\"] ++;
  19. } else {
  20. $table[$leagues['home_club_id']][&#092;"home_draws\"] ++;
  21. $table[$leagues['home_club_id']][&#092;"home_pts\"] += 1;
  22. $table[$leagues['away_club_id']][&#092;"away_draws\"] ++;
  23. $table[$leagues['away_club_id']][&#092;"away_pts\"] += 1;
  24. }
  25. }
  26.  
  27. ?>


zsumowalem wszystkie mecze aby zrobic tabele ligowa
i teraz jak wyciagnac tabele posortowana wzgledem home_pts+away_pts;


--------------------
pozdrawiam :)
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: 21.06.2025 - 23:09