hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 Nē, man vajag lai tos skaitļus "1,5,8,4,6" viņš saskaitītu un tad izvadītu saskaitīto rezutlātu, nevis "15846" :) Link to comment Share on other sites More sharing options...
andrisp Posted May 24, 2007 Report Share Posted May 24, 2007 list($skaits) = mysq_fetch_row(mysql_query("SELECT COUNT(*) FROM `tabula`")); Link to comment Share on other sites More sharing options...
bubu Posted May 24, 2007 Report Share Posted May 24, 2007 echo "$x"; izvada $x vērtību neko nesaskaitot. Saskaitīšanu php valodā veic izmantojot + operatoru. Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 andrisp varbūt vari palīdzēt salikt kopā? :D es te kādu laiku pamudžinājos, bet nekas nesanāca... pašlaik kkas tml ir... $result = mysql_query("SELECT count(*) FROM tabula"); while($row = mysql_fetch_array($result)) { $skaits = $row['count(*)']; echo "$skaits"; } Link to comment Share on other sites More sharing options...
Kavacky Posted May 24, 2007 Report Share Posted May 24, 2007 COUNT(*) atgriež rindu skaitu tabulā - vienu lielumu vienu reizi. Cik reizes no tā var vilkt ārā jaunas rindas? Un $row['count(*)'] ir LOL. "SELECT COUNT(*) AS `skaits`" -> $row['skaits'] gan var. Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 Nu jā, kautvai...Bet pastāsti, kā un kur jāpieliek tas andrip piemērs ;D Link to comment Share on other sites More sharing options...
bubu Posted May 24, 2007 Report Share Posted May 24, 2007 echo $skaits; andrap piemēram galā ir jāpieliek. Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 (edited) Nu jā...a tas pārējais kods maz ir vajadzīgs? :D edit: viss ok :) paldies Edited May 24, 2007 by hackerman Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 for ($i = 1; $i <= $dala; $i++) { echo "<a href=\"yeah\">1</a><br>"; } A kā var uztaisīt, lai viņš katru nākamo skaita tālāk, nevis visus kā 1 parāda? Link to comment Share on other sites More sharing options...
andrisp Posted May 24, 2007 Report Share Posted May 24, 2007 Nu vispār: for ($i = 1; $i <= $dala; $i++) { echo "<a href=\"yeah\">".$i."</a><br>"; } Tu domā arī vispār ? Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 (edited) Ok, nu man kods ~ tāds - http://paste.php.lv/5574 Ko man likt pie id? Aizmirsu pielikt (int) .. Ko vēl tur vajadzētu? Piem., ja man nav definēts id tur, tad ir ~ tāds errors: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource edit: pie reizes, kā var noapaļot skaitli? piem dalot tur sanāk 2.6, bet vajag 2.6-> 3 :) Kā var noapaļot? Edited May 24, 2007 by hackerman Link to comment Share on other sites More sharing options...
bubu Posted May 24, 2007 Report Share Posted May 24, 2007 http://lv.php.net/round http://lv.php.net/floor http://lv.php.net/ceil Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 Cik skatījos, visas tās ir noapaļošanas fcijas.. Kā paliek ar to erroru? Link to comment Share on other sites More sharing options...
andrisp Posted May 24, 2007 Report Share Posted May 24, 2007 if($_GET['id'] == 1){ $result = mysql_query("SELECT count(*) FROM tabule ORDER BY count(*) DESC LIMIT 0, 10"); }else{ } if($_GET['id'] == 2){ $result = mysql_query("SELECT count(*) FROM tabule ORDER BY count(*) DESC LIMIT 0, 10"); }else{ } Pastāsti, ko tu te mēģini izdarīt. Link to comment Share on other sites More sharing options...
hackerman Posted May 24, 2007 Author Report Share Posted May 24, 2007 Bļin atkal es aprāvos :D http://paste.php.lv/5578 - papildinats Es tā padomāju..Tas veids nav tas pareizākais .. Jābūt savādākam veidam kā to noteikt. Karoč tur es caur id padodu viņam kveriju. Nu šķirstu lapu, id=1, padodam kveriju ar noteiktu LIMIT :) Ir varbūt jēdzīgāks veids kā to panākt? Link to comment Share on other sites More sharing options...
Recommended Posts