Jump to content
php.lv forumi

atbilžu skaitīšana count(*)


anonīms

Recommended Posts

Nepieciešams, lai forumā kods saskaitītu cik pavisam ir atbildes zem šī foruma, bet viņš tikai skaita no 1 topika

 

  $pcnt = mysql_query("SELECT count(*) as cnt FROM forums_topiki where kategorijas_id = $forums[0] ");
  $pcnt = mysql_fetch_array($pcnt);
  $pcnt = $pcnt[cnt];


////////////////////////////////////////////////////////



// Atbildes
$atbildes_foruma_sakumaa = mysql_query("SELECT id FROM forums_topiki where kategorijas_id = $forums[0]");
$atbildes_foruma_sakumaa = mysql_fetch_array($atbildes_foruma_sakumaa);
$pcnt3 = mysql_query("SELECT count(*) as cnt3 FROM forums_atbildes WHERE topika_id = $atbildes_foruma_sakumaa[0] ");
  $pcnt3 = mysql_fetch_array($pcnt3);
  $pcnt3 = $pcnt3[cnt3];

echo "<td><div style='text-align: center;'>".$pcnt3."</div></td></tr>";

Edited by anonīms
Link to comment
Share on other sites

SELECT COUNT(forums_atbildes.id) AS skaits FROM forums_atbildes, forums_topiki WHERE forums_atbildes.topika_id = forums_topiki.id AND forums_topiki.kategorijas_id = ' . $forums[0]

 

P.S. Vispār jau vajag arī tabulu struktūru norādīt, ja prasi ko šādu, jo tās kristāla bumbas ir liels deficīts... ;)

Link to comment
Share on other sites

×
×
  • Create New...