march Posted February 19, 2006 Report Share Posted February 19, 2006 (edited) Tātad kā precīzi jāraksta lai kā mainīgā vērtība izvadītos visu skaitļu (int) summa, kas sarakstīti vienā tabulas kolonnā? Zinu, tāds topiks jau ir bijis, bet pēc tā man nekas nesanāca. Edited February 19, 2006 by march Link to comment Share on other sites More sharing options...
Vebers Posted February 19, 2006 Report Share Posted February 19, 2006 SELECT SUM(kolonna) FROM tabula WHERE tas=sis Link to comment Share on other sites More sharing options...
march Posted February 19, 2006 Author Report Share Posted February 19, 2006 Šito zinu, bet kā dabūt to skaitli kā mainīgā vērtību? Link to comment Share on other sites More sharing options...
Vebers Posted February 19, 2006 Report Share Posted February 19, 2006 $q=mysql_query("SELECT SUM(kolonna) FROM tabula WHERE tas=sis"); $q=mysql_fetch_row($q); $skaitlis=$q[0]; Link to comment Share on other sites More sharing options...
march Posted February 19, 2006 Author Report Share Posted February 19, 2006 Tnx, tagad viss skaidrs Link to comment Share on other sites More sharing options...
bubu Posted February 19, 2006 Report Share Posted February 19, 2006 Tak šī kverija datus dabū tāpat taču kā jebkuru cita kverija datus: ar jebkuru no mysql_fetch_* funkcijām. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 19, 2006 Report Share Posted February 19, 2006 MakaTaNaw--> nevienmeer tas ir erti jo ja buus daudz kolonuu tad viegli var apjukt :( $q=mysql_query("SELECT SUM(kolonna) AS kautkaads_nosaukums FROM..... ............. $skaitlis=$q['kautkaads_nosaukums ']; saadi arii var :) un tas ir daudz vieglaak uztverams un krietni mazaaka iespeeja pielaist kljuudu Link to comment Share on other sites More sharing options...
bubu Posted February 19, 2006 Report Share Posted February 19, 2006 Grey_Wolf: Kautkā nekur nemanīju, ka viņš apgalvotu, ka tā ir visērtāk. Viņš tikai atbildēja uz jautājumu. Pie tam tavā tekstā ir tipiska iesācēja kļūda: kur mysql_fetch_...? Ja kas, tad es arī izmantoju tikai mysql_fetch_row funkciju :) Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 19, 2006 Report Share Posted February 19, 2006 bubu -->kaadeelj gan kljuuda? Link to comment Share on other sites More sharing options...
bubu Posted February 19, 2006 Report Share Posted February 19, 2006 $q=mysql_query("SELECT SUM(kolonna) AS kautkaads_nosaukums FROM..... print_r($q); // MySQL resource #id... kautkas tāds $res = mysql_fetch_assoc($q); print_r($res); // normāls asociatīvs masīvs $skaitlis=$res['kautkaads_nosaukums ']; // ņemam no rezultāta nevis kverija atgrieztās vērtības. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted February 19, 2006 Report Share Posted February 19, 2006 bubu--> ta es uzreiz nesapratu tavu domu :( ta nee es vienkarshi to dalju neuzrakstiju :( P.S. varjau buut ka vajadzeeja bet aizvietoju ar ..... Link to comment Share on other sites More sharing options...
Recommended Posts