spynode Posted April 9, 2004 Report Share Posted April 9, 2004 kaa es vareetu saskaitiit tabulaa visus ierakstus kuriem raksta_id = 7 (piemeeram), un pec tam to skaitli ka mainigo turet ? Link to comment Share on other sites More sharing options...
Gacha Posted April 9, 2004 Report Share Posted April 9, 2004 Šis varetu būt: $mainigais = mysql_query("select count(*) from table where id='7'"); Link to comment Share on other sites More sharing options...
bubu Posted April 9, 2004 Report Share Posted April 9, 2004 :) nee Gacha taa neies. vajag shaadi: $res = mysql_query("select count(*) from table where id='7'"); $row = mysql_fetch_row($res); mysql_free_result($res); $skaits = $row[0]; Link to comment Share on other sites More sharing options...
spynode Posted April 9, 2004 Author Report Share Posted April 9, 2004 senks Link to comment Share on other sites More sharing options...
spynode Posted April 9, 2004 Author Report Share Posted April 9, 2004 man izmet shitaadu kljuudu - Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Group\Apache2\htdocs\raksti.php on line 10. Tas ir shitai rindai - $skait_kver = mysql_query ("select count(*) from komenti where 'raksta_id' = '$row['id']'"); Link to comment Share on other sites More sharing options...
Aleksejs Posted April 9, 2004 Report Share Posted April 9, 2004 $skait_kver = mysql_query ("select count(*) from komenti where 'raksta_id' = '" . $row['id'] . "'"); Link to comment Share on other sites More sharing options...
spynode Posted April 9, 2004 Author Report Share Posted April 9, 2004 (edited) Man tas skaitlis ($komenti_num) visu laiku ir 0. Kods : $result = mysql_query ("Select * from raksti order by id desc"); if (!$result) echo( mysql_error()); else { while ($row = mysql_fetch_array($result)) { $skait_kver = mysql_query ("select count(*) from komenti where 'raksta_id' = '" . $row['id'] . "'"); $kom_skait = mysql_fetch_row($skait_kver); mysql_free_result($skait_kver); $komenti_num = $kom_skait[0]; Edited April 9, 2004 by spynode Link to comment Share on other sites More sharing options...
Aleksejs Posted April 9, 2004 Report Share Posted April 9, 2004 tas tāpēc, ka domājams kolonna raksta_id nav teksta virkne, bet gan cipars. Noņem nevajadzīgās pēdiņas. $skait_kver = mysql_query ("select count(*) from komenti where raksta_id = " . $row['id']); Link to comment Share on other sites More sharing options...
fassko Posted April 9, 2004 Report Share Posted April 9, 2004 $mainigais = mysql_query("select * from table where id='7'"); $sk = mysql_num_rows($mainigais); print "$sk"; //skaits var arii shaadi, bet diemzheel nepateikshu kaa labaak tb. aatraak Link to comment Share on other sites More sharing options...
bubu Posted April 10, 2004 Report Share Posted April 10, 2004 2 fassko: tavs piemeers buus nezheeliigi LEENS, jo php vajadzees izvilkt visus datus no DB, lai saskaitiitu rindinjas, a select count(*) dara to ka pats saskaita viltiigaa veidaa rindinju skaitu, un vienalga kaadi un cik lieli dati tur glabaajaas 2 spynode: a shaadi nestraadaa (pirms tam mysql_connect esi izdariijis? un ja vajag katram raksta id dabuut komentaaru skaitu var jau shaadi dariit: SELECT raksti.id, count(*) FROM raksti, komenti WHERE raksti.id=komenti.id GROUP BY raksti.id ORDER BY raksti.id DESC Protams to WHERE dalju uzraksti kaa tev vajag. Link to comment Share on other sites More sharing options...
Ugga Posted April 13, 2004 Report Share Posted April 13, 2004 $mainigais = mysql_query("select * from table where id='7'");$sk = mysql_num_rows($mainigais); print "$sk"; //skaits tas ir iistais risinaajums Link to comment Share on other sites More sharing options...
Recommended Posts