Autor Zpráva
Frankes
Profil
Zdravím, udělal jsem si {minitabulky na fotbal do které zadávám body, ty se mi poté zobrazí v tabulce}

Dotaz. { Jak udělám to že se mi týmy v tabulce seřadí podle bodů vzestupně?}

zde je code minitabulky

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Current Standings</title>
<style type="text/css">
body,
td {
  
    font: 12px/1.5 "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    text-align:center;
     color:black;
} 
th {
  
    font: 12px/1.5 "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    text-align:center;
    color:red;
}
.red {
  
    font: 12px/1.5 "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    text-align:center;
    color:red;
}
a{text-decoration: none}
a:link    {color: black}
a:visited    {color: black}
a:active    {color: orange} 
a:hover    {color: blue} 

th {
    text-align: left;
}

.standingstable {


    

color:#ffffff;
}
.bunka {
 
    color:black;
}
h2    {color: black; font-style: italic}
.radek_suda {
  background-color:#808080;
  
}
h3    {color: black; font-style: italic}
.radek_suda {
  background-color:#808080;
  
}
.radek_licha {
  background-color:#696969;
}
.radek_suda_red {
  color: red;
    background-color:#808080;
    font: 13px/1.5 "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    text-align:center;
    color:red;
}
.radek_licha_red {
  color: red;
    background-color:#696969;
    font: 13px/1.5 "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
    text-align:center;
    color:red;
}

.gamestable, .scorestable, .teamhistory {
border-collapse: collapse;
margin-top: 10px;
margin-bottom: 10px;

}

.gamestable td, .gamestable th, .scorestable td, .scorestable th, .teamhistory td, .teamhistory th {
padding: 0px;
border: 1px solid with;
}

.gamestable tr, .scorestable tr, .teamhistory tr {
vertical-align: top;
}
.footer {
text-align: center;
margin-bottom: 40px;
font-size: 12px;
}
</style>

</head></body><center>


<table class="standingstable">
    <tr>

        <td width="20%"><strong>Logo</strong></a></td>
        <td width="20%"><strong>Nick</strong></a></td>       
        <td width="20%"><strong>Body</strong></td>

    </tr>

    <tr>
        <td>        <img src="http://www.pas.jabko.net/standings/loga/AC%20Milan.png">
</td>
        <td>N?kdo</td> 
        <td>15</td> 
    </tr>
    <tr>
        <td>        <img src="http://www.pas.jabko.net/standings/loga/Manchester%20City.png">
</td>
        <td>N?kdo</td> 
        <td>8</td> 
    </tr>
    <tr>
        <td>        <img src="http://www.pas.jabko.net/standings/loga/Chelsea%20London.png">
</td>
        <td>N?kdo</td> 
        <td>6</td> 
    </tr>
    <tr>
        <td>        <img src="http://www.pas.jabko.net/standings/loga/Bayern%20Mnichov.png">
</td>
        <td>N?kdo</td> 
        <td>6</td> 
    </tr>
    <tr>
        <td>        <img src="http://www.pas.jabko.net/standings/loga/Fiorentina.png">
</td>
        <td>N?kdo</td> 
        <td>10</td> 
    </tr>
</table>




</html>
_construct
Profil *
array_multisort();
Frankes
Profil
Jsem amatér mohl by ste mi to vložit přímo do toho kodu nevím kam to tam mám vložit a co do toho napsat.
_connsruct
Profil *
<?php

class ArrayMultisort {
    
    public $DataArray;
    public $Headers;

    function __construct($DataArray, $Headers=NULL) {
        /* Magic Method */
        $this->DataArray = $DataArray;
        $this->Headers = $Headers;
    }

    public function SortDataArray($SortByCol, $Direction, $Type){
        /* Sort multiple or multi-dimensional arrays */
        if(is_array($this->DataArray)){
            $SortCol = array();
            foreach($this->DataArray as $Row => $Line){
                $SortCol[] = $Line[$SortByCol];
            }
            return array_multisort($SortCol, $Direction, $Type, $this->DataArray);
            /*****
            Vstupné polia sa spracujú ako stĺpce tabuľky, ktorá sa má triediť podľa riadkov - toto sa podobá klauzule SQL ORDER BY. 
            Prvé pole je primárne, podľa ktorého sa zoraďuje.
            Defaultné Návestia SORT_ASC a SORT_REGULAR. 
            
            $Direction - Návestia smeru zoradenia: 
                SORT_ASC - zoradiť vzostupne
                SORT_DESC - zoradiť zostupne
                
            $Type - Návestia typov zoradenia: 
                SORT_REGULAR - porovnávať položky normálne
                SORT_NUMERIC - porovnávať položky číselné
                SORT_STRING - porovnávať položky ako reťazce
                
            */
        }
    }
    
    public function Table() {
        /* Fuj Table */
        if(is_array($this->DataArray)) {
            $Table = "<table>\n";
            
            if(is_array($this->Headers)){
                $Table.= "<tr>\n";
                foreach($this->Headers as $Column => $Header) {
                    $Table.= '<th>'.$Header."</th>\n";
                }
                $Table.= "</tr>\n";
            }
            
            foreach($this->DataArray as $Row => $Line) {
                $Table.= "<tr>\n";
                foreach($Line as $Column => $Value) {
                    $Table.= '<td>'.$Value."</td>\n";
                }
                $Table.= "</tr>\n";
            }
            
            $Table.= "</table>\n";
            
            return $Table;
        }
    }
    
}

$Headers = array('Logo', 'Nick', 'Body');
$Array = array(
    array('<img src="http://www.pas.jabko.net/standings/loga/AC%20Milan.png">','N?kdo','15'),
    array('<img src="http://www.pas.jabko.net/standings/loga/Manchester%20City.png">','N?kdo','8'),
    array('<img src="http://www.pas.jabko.net/standings/loga/Chelsea%20London.png">','N?kdo','6'),
    array('<img src="http://www.pas.jabko.net/standings/loga/Bayern%20Mnichov.png">','N?kdo','6'),
    array('<img src="http://www.pas.jabko.net/standings/loga/Fiorentina.png">','N?kdo','10'),
    );
$Handle = new ArrayMultisort($Array, $Headers);
print $Handle->Table();
$Handle->SortDataArray(2, SORT_DESC, SORT_NUMERIC);
print $Handle->Table();

?>



Chybička se vloudila...
řádek 8: public function __construct(...

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: