phpbar.de logo

Mailinglisten-Archive

[php] mySQL Ergebnis umwandeln

[php] mySQL Ergebnis umwandeln

Thomas Beckmann php_(at)_phpcenter.de
Sun, 19 Aug 2001 20:52:00 +0200


>ich habe folgendes Ergebnis aus einer Datenbankabfrage:
>while($info=3Dmysql_fetch_assoc($result))
>{
>         print_r($info);
>         print("<BR>\n");
>}
>
>Array ( [acID] =3D> 8 [aeID] =3D> 3 [azID] =3D> 7 )
>Array ( [acID] =3D> 8 [aeID] =3D> 3 [azID] =3D> 8 )
>Array ( [acID] =3D> 8 [aeID] =3D> 3 [azID] =3D> 9 )
>Array ( [acID] =3D> 9 [aeID] =3D> 3 [azID] =3D> 7 )
>Array ( [acID] =3D> 9 [aeID] =3D> 3 [azID] =3D> 8 )
>Array ( [acID] =3D> 9 [aeID] =3D> 3 [azID] =3D> 9 )
>Array ( [acID] =3D> 8 [aeID] =3D> 4 [azID] =3D> 7 )
>Array ( [acID] =3D> 8 [aeID] =3D> 4 [azID] =3D> 8 )
>Array ( [acID] =3D> 8 [aeID] =3D> 4 [azID] =3D> 9 )
>Array ( [acID] =3D> 9 [aeID] =3D> 4 [azID] =3D> 7 )
>Array ( [acID] =3D> 9 [aeID] =3D> 4 [azID] =3D> 8 )
>Array ( [acID] =3D> 9 [aeID] =3D> 4 [azID] =3D> 9 )
>
>Das ist nat=FCrlich K=E4se, ich brauche das in folgender Form um damit =
weiter=20
>arbeiten zu k=F6nnen:
>Array ( [acID1] =3D> 8 [acID2] =3D> 9 [aeID1] =3D> 3 [aeID2] =3D> 4 =
[azID1] =3D> 7=20
>[azID2] =3D> 8 [azID3] =3D> 9 )
>oder:
>Array ( [0] =3D> 8 [1] =3D> 9 )
>Array ( [0] =3D> 3 [1] =3D> 4 )
>Array ( [0] =3D> 7 [1] =3D> 8 [2] =3D> 9 )
>
>wobei acID, aeID und azID beliebig viele verschiedene Werte haben =
k=F6nnen.
>Ich m=FC=DFte also auf $result nochmal jeweils einen Query ausf=FChren =
der mir=20
>ID's gruppiert.
gSchau' Dir mal die GROUP BY Anweisung und die SUM-Funktionen in MySQL
an, ich glaube, damit ist Dir geholfen.

---
Thomas Beckmann, Kiel, Germany
beckmann_(at)_gis.de


php::bar PHP Wiki   -   Listenarchive