sfx Posted January 17, 2006 Report Share Posted January 17, 2006 $query = "SELECT * FROM `tab`"; $result = mysql_query($query); while($dati = mysql_fetch_row($result)){ echo"$dati[1] - $dati[2]": } $dati[2] ir kautkaadi skaitlji, kaa lai tos saskaita un dabuuju summu. Link to comment Share on other sites More sharing options...
andrisp Posted January 17, 2006 Report Share Posted January 17, 2006 neliec izvadi peedinjaas Link to comment Share on other sites More sharing options...
Vebers Posted January 17, 2006 Report Share Posted January 17, 2006 MySQL ir tāda lieliska funkcija kā SUM();. kura saskaita uzreiz visu kolonnu. Piemēram: -------------------------- |Vards | kukuļi_maize| -------------------------- |Jānis | 3 | |Ilze | 1 | |Laima | 5 | ---------------------------- SELECT SUM(kukulji_maize) as summa FROM tabula Bet vari jau arii kā biji sācis. $summa = ''; $query = "SELECT * FROM `tab`"; $result = mysql_query($query); while($dati = mysql_fetch_row($result)){ echo"$dati[1] - $dati[2]": $summa .= $summa + $dati[2]; } Link to comment Share on other sites More sharing options...
sfx Posted January 17, 2006 Author Report Share Posted January 17, 2006 Es izdariiju shadi: $summa = ''; $query = "SELECT * FROM `tab`"; $result = mysql_query($query); while($dati = mysql_fetch_row($result)){ echo"$dati[1] - $dati[2]": $summa .= $summa + $dati[2]; } print"$summa"; Rezultaataa [print"$summa";] bija kautkas nesakariigs, skaitlju rinda [3710722337110682 ] kura nebija summa bet gan ieprieksheejais rezultaas plus naakoshais rezultaats: 3710 72233 7110682 Kas nav pareizi? Link to comment Share on other sites More sharing options...
[Ya] Posted January 17, 2006 Report Share Posted January 17, 2006 (edited) To: MakaTaNaw hehe tip ar domu: 1.=1+1; 12.=12+2; 1214.=1214+3; 12141217.=........ utt ... $summa .= $summa + $dati[2]; šo rindiņu pamaini pret : $summa+=$dati[2]; Edited January 17, 2006 by [Ya] Link to comment Share on other sites More sharing options...
Vebers Posted January 17, 2006 Report Share Posted January 17, 2006 $summa = $summa + $dati[2]; Bez tā punkta pirms ir zīmes.. Link to comment Share on other sites More sharing options...
sfx Posted January 17, 2006 Author Report Share Posted January 17, 2006 PALDIES, VISS ok! :) Link to comment Share on other sites More sharing options...
Recommended Posts