Jump to content
php.lv forumi

MySQL ieraksti


spynode

Recommended Posts

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

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 by spynode
Link to comment
Share on other sites

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

×
×
  • Create New...