twocoders.de
 

programme/php/mehrdimarraysortieren/sort.php


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

    <head>
        <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
        <title>Untitled Page</title>
        <style type="text/css" media="screen"><!--
        #layer1 { visibility: visible; position: absolute; top: 0px; left: 0px; width: 113px; height: 400px }
        #layer2 { visibility: visible; position: absolute; top: 0px; left: 113px; width: 113px; height: 400px }
        #layer3 { visibility: visible; position: absolute; top: 0px; left: 226px; width: 113px; height: 400px }
        #layer4 { visibility: visible; position: absolute; top: 0px; left: 339px; width: 113px; height: 400px }
        --></style>
        <?php
        $Waren 
= array();
        
$Waren[0][0] = "Glühbirne";
        
$Waren[0][1] = 300;
        
$Waren[0][2] = 2.50;
        
$Waren[0][3] = 1199142000;
        
        
$Waren[1][0] = "Luftpumpe";
        
$Waren[1][1] = 50;
        
$Waren[1][2] = 7.99;
        
$Waren[1][3] = 1174860000;
        
        
$Waren[2][0] = "Tasse";
        
$Waren[2][1] = 20;
        
$Waren[2][2] = 5.99;
        
$Waren[2][3] = 1178920800;
                
        
$Waren[3][0] = "CD-Player";
        
$Waren[3][1] = 10;
        
$Waren[3][2] = 49.20;
        
$Waren[3][3] = 1178229600;
        
        
$Waren[4][0] = "USB-Stick";
        
$Waren[4][1] = 70;
        
$Waren[4][2] = 38.50;
        
$Waren[4][3] = 1187992800;
        
        
$Waren[5][0] = "Locher";
        
$Waren[5][1] = 3;
        
$Waren[5][2] = 3.99;
        
$Waren[5][3] = 1178920800;
        
//----------------------------Function--------------------------

        
$Typ intval($_GET["Typ"]);
        
$Feld intval($_GET["Feld"]);
        
        if(
$Typ == "" || $Feld == "")
        {
            
$Typ 1;
            
$Feld 1;
        }
                
        if (
$Typ == 2)
                
$SortierModus SORT_DESC;
        else
                
$SortierModus SORT_ASC;
                
        if (
$Feld == 1)
                
$Typ SORT_STRING;
        else
                
$Typ SORT_NUMERIC;
    
        
$Waren MehrDimArSort($Waren$Feld 1$SortierModus$Typ);
        
//                    Array, Richtarray,(Aufsteigend,Absteigend),(String,Zahl)
        
        //--------------------------------Function-------------------------------------
        
function MehrDimArSort($data$Sortierarray,$SotModus$Typ)
        {
            
$sortArray = array();
            foreach(
$data as $key => $array
            {
                
$sortArray[$key] = $array[$Sortierarray];
            }
            
array_multisort($sortArray$SotModus$Typ$data);
            if(
array_multisort($sortArray$SotModus$Typ$data))
                return 
$data;
            else
                return 
false;
        }
        
?>
    </head>

    <body>
        <div id="layer1">
            Name
            <a href="sort.php?Typ=1&Feld=1"><img src="pfeil-oben.gif" alt="" height="12" width="12" border="0"></a><a href="sort.php?Typ=2&Feld=1"><img src="pfeil-unten.gif" alt="" height="12" width="12" border="0"></a><?php
            
for($Zeile 0$Zeile 6$Zeile ++)
            {
                echo 
"<br>".$Waren[$Zeile][0];
            }
            
?></div>
        <div id="layer2">
            St&uuml;ckzahl<a href="sort.php?Typ=1&Feld=2"><img src="pfeil-oben.gif" alt="" height="12" width="12" border="0"></a><a href="sort.php?Typ=2&Feld=2"><img src="pfeil-unten.gif" alt="" height="12" width="12" border="0"></a> <?php
            
for($Zeile 0$Zeile 6$Zeile ++)
            {
                echo 
"<br>".$Waren[$Zeile][1];
            }
            
?>
            </div>
        <div id="layer3">
            Preis<a href="sort.php?Typ=1&Feld=3"><img src="pfeil-oben.gif" alt="" height="12" width="12" border="0"></a><a href="sort.php?Typ=2&Feld=3"><img src="pfeil-unten.gif" alt="" height="12" width="12" border="0"></a> <?php
            
for($Zeile 0$Zeile 6$Zeile ++)
            {
                echo 
"<br>".round($Waren[$Zeile][2],2)." &euro;";
            }
            
?>
            </div>
        <div id="layer4">
            Lieferbar<a href="sort.php?Typ=1&Feld=4"><img src="pfeil-oben.gif" alt="" height="12" width="11" border="0"></a><a href="sort.php?Typ=2&Feld=4"><img src="pfeil-unten.gif" alt="" height="12" width="10" border="0"></a> <?php
            
for($Zeile 0$Zeile 6$Zeile ++)
            {
                echo 
"<br>".date("d-m-Y",$Waren[$Zeile][3]);
            }
            
?>
            </div>
    </body>

</html>