![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Dołączył: 18.03.2011 Ostrzeżenie: (0%) ![]() ![]() |
Witam.
Ostatnio zacząłem pisać kod PHP na Ligi piłkarskie. Przykład działania kodu. Manchester United|26|46|11|62|manchester-united.jpg Poszczególne liczby oznaczają wygrane mecze,przegrane itd. wszystko mam napisane lecz nie chce mi to za bardzo działać Poniżej podam wam kody i powiecie mi czy wszystko z nimi jest ok. Index.php Kod <body> <ol> <?php foreach ($menu as $opcja) : ?> <li> <a href="index.php?module=liga&action=show&liga=<?php echo $opcja[1]; ?>"> <?php echo $opcja[0]; ?> </a> </li> <?php endforeach; ?> </ol> <?php include "modules/$module/$action"; ?> </body> <a href="index.php?module=liga&action=show&liga=ang&kolumna=1&order=asc">Klub</a> ligicontroller.class.php Kod class LigiController extend Controller { public function preActions() { $tmp = string2HArry(file_get_contents('ligi.txt')); $this->dane - $tmp['items']; $this->slugi = array(); forach ($this->dane as $liga){ $this->slugi[] = $liga[1]; } $this->set('menu', $this->dane); } } modules/actions.class.php Kod class Actions extends ActionsBase { private $kolumna = 5; private 4kolumny = array( 1 => array ('nazwa' => 'Klub', 'order' => 'asc'), array ('nazwa'=> 'Mecze', 'order' => 'desc'), array ('nazwa' => 'Bramki strzelone', 'order' => 'desc'), array ('nazwa' => 'Bramki stracone', 'order' => 'desc'), array ('nazwa' => 'Punkty', 'order' => 'desc') ); public function strInvertSort($s) { if ($s == 'asc'){ return 'desc'; } else { return 'asc';} } } public function strGetSort($s) { if ($s == 'asc') { return SORT_ASC; } else{ return SORT_DESC; } } public function getCurrentSort() { $tmp = $this->kolumny[$this->kolumna]['order']; return $this->strGetSort($tmp); } public function invertCurrentSort() { $tmp = $this->kolumny[$this->kolumna]['order']; $this->kolumny[$this->kolumna]['order'] = $this->strInvertSort($tmp); } public function sort() { switch (this->kolumna){ case 1: array_multisort( $this->tabela['items'][0], $this->getCurrentSort(). $this->tabela['items'][1], $this->tabela['items'][2], $this->tabela['items'][3], $this->tabela['items'][4] ); break; case 2; } } public function execute_show() { if ( isset($_GET['liga']) && str_invslug($_GET['liga']) && in_array($_GET['liga'], $this->controller->slugi) ) { $liga = $_GET['liga']; } else { $liga = $this->controller->dane[0][0]; } if ( isset($_GET['kolumna']) && str_ievpifr($_GET['kolumna'], 1, 5) ) { $this->kolumna = $_GET['kolumna']; } if ( isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ) { $this->kolumny[$this->kolumna]['order'] = $_GET['order']; } $indeks = array_search($liga, $this->controller->slugi); $tmp = $this->controller->dane[$indeks][1]; $this->tabela = string2VArray(file_get_contents('../scripts/dance/'$tmp . '.txt')); $this->sort(); $this->invertCurrentSort(); $this->set('kolumny', $this->kolumny); $this->set('liga', $liga); $this->set('tabela', $this->tabela); } } modules/liga/show.php Kod <table> <tr> <th>lp.</th> <th>Godło</th> <?php foreach ($kolumny as $k => $v) : ?> <th> <a href="index.php?module=liga&action=show&liga=<?php echo $liga; ?>$kolumna=<?php echo $k; ?>&order=<?php echo $v['order']; ?>"> <?php echo $v['nazwa']; ?> </a> </th> <?php edforeach; ?> </tr> <?php for ($i = 0; $i < $tabela['rows']; $i++) : ?> <tr> <td><?php echo $i +1; ?></td> <td> <img src="<?php echo $path_prefix: ?>/<?php echo $tabela['items'][5][1];?>" alt="" /> </td> <?php for ($j = 0; $j < $tabela ['cols'] - 1; $j++) : ?> <td> <?php echo $tabela ['items'] [$j][$i]; ?> </td> <?php endfor; ?> </tr> <?php endfor; ?> </table> modules/liga/actions.class.php Kod class Actions extends ActionsBase { private $kolumna = 5; private 4kolumny = array( 1 => array ('nazwa' => 'Klub', 'order' => 'asc'), array ('nazwa'=> 'Mecze', 'order' => 'desc'), array ('nazwa' => 'Bramki strzelone', 'order' => 'desc'), array ('nazwa' => 'Bramki stracone', 'order' => 'desc'), array ('nazwa' => 'Punkty', 'order' => 'desc') ); public function strInvertSort($s) { if ($s == 'asc'){ return 'desc'; } else { return 'asc';} } } public function strGetSort($s) { if ($s == 'asc') { return SORT_ASC; } else{ return SORT_DESC; } } public function getCurrentSort() { $tmp = $this->kolumny[$this->kolumna]['order']; return $this->strGetSort($tmp); } public function invertCurrentSort() { $tmp = $this->kolumny[$this->kolumna]['order']; $this->kolumny[$this->kolumna]['order'] = $this->strInvertSort($tmp); } public function sort() { switch (this->kolumna){ case 1: array_multisort( $this->tabela['items'][0], $this->getCurrentSort(). $this->tabela['items'][1], $this->tabela['items'][2], $this->tabela['items'][3], $this->tabela['items'][4] ); break; case 2; } } public function execute_show() { if ( isset($_GET['liga']) && str_invslug($_GET['liga']) && in_array($_GET['liga'], $this->controller->slugi) ) { $liga = $_GET['liga']; } else { $liga = $this->controller->dane[0][0]; } if ( isset($_GET['kolumna']) && str_ievpifr($_GET['kolumna'], 1, 5) ) { $this->kolumna = $_GET['kolumna']; } if ( isset($_GET['order']) && in_array($_GET['order'], array('asc', 'desc')) ) { $this->kolumny[$this->kolumna]['order'] = $_GET['order']; } $indeks = array_search($liga, $this->controller->slugi); $tmp = $this->controller->dane[$indeks][1]; $this->tabela = string2VArray(file_get_contents('../scripts/dance/'$tmp . '.txt')); $this->sort(); $this->invertCurrentSort(); $this->set('kolumny', $this->kolumny); $this->set('liga', $liga); $this->set('tabela', $this->tabela); } } Błąd który mi wyskakuje ![]() To na tyle.Przez kilka godzin pisania trochę się zamotałem, ale mam nadzieję że mi pomożecie dojść do ładu i składu ![]() Pozdrawiam i czekam na odpowiedzi. Ten post edytował miriadel 18.03.2011, 00:49:26 |
|
|
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 1 495 Pomógł: 245 Dołączył: 1.07.2009 Skąd: Bydgoszcz Ostrzeżenie: (0%) ![]() ![]() |
Wklej te kody najpierw w znaczniki php a nie code bo nawet linijek nie numeruje.
PS. Za zdublowanie tematu w najlepszym razie moderator zamknie Ci oba. Za tekst "nie mam czasu pisać posta od nowa" już wróżę ostrzeżenie + zamknięcie obu tematów ;P Ten post edytował sadistic_son 18.03.2011, 01:09:44 -------------------- Uśpieni przez system, wychowani przez media,
Karmieni zmysłami, próżnymi żądzami... -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Jesteś zbyt leniwy, żeby się zarejestrować? Ja jestem zbyt leniwy aby Ci pomóc! -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |
|
|
![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 7 Pomógł: 0 Dołączył: 18.03.2011 Ostrzeżenie: (0%) ![]() ![]() |
Ok powklejałem w znaczniki php ale błąd nadal jest ^^ i zniknąć nie chce
![]() |
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 324 Pomógł: 52 Dołączył: 18.02.2008 Ostrzeżenie: (0%) ![]() ![]() |
a czytać umiesz ? Przecież pisze że nie jest nie zdefiniowana zmienna w linii 1 (nie ma definicji tablicy $menu). To samo w linii 11. Na ten kawałek kodu takie coś
masz ?: czy inne wartości tablicy ? gino PS. Nie zrobiłeś tego o czym pisał sadistic_son kody w znaczniki php Ten post edytował gino 18.03.2011, 08:08:15 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 21.08.2025 - 06:12 |