RaaapuLis Posted August 14, 2008 Report Share Posted August 14, 2008 kr4 vleos lai ir nevis Komentari, bet Komentari (skaits) $komsk=mysql_query("SELECT COUNT(*) FROM komentaari WHERE raksta_id='.$raksta_id.'"); un vieta kur velso tos komentarus izvadu ar echo $komsk echo "<h3 class='news_title'>...</h3><br /> <br /><br><strong>...</strong>DATUMS | <a href='...'><strong>Komentāri ($komsk)</strong></a> <br /><br><br /><br><br>"; daudzpunktēm nepievērst uzmanību! Bet neizvada skaitu :/ Izvada šo Resource id #5 kas nepareizs?, db piekonektējas Link to comment Share on other sites More sharing options...
duplets Posted August 14, 2008 Report Share Posted August 14, 2008 Esi aizmirsis kveri apstrādāt ar mysql_fetch_array! Un vispār ieteiktu komentāru skaitu updeitot pie komentāru pievienošanas, nevis, kad tu velc visu infu ārā! Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 (edited) nu ja iesāki tad pabeidz, iedod piemēru.. vispār tas ir iespējams ieksh mysql_fetch_array vel viens mysql_fetch_row? Edited August 14, 2008 by RaaapuLis Link to comment Share on other sites More sharing options...
duplets Posted August 14, 2008 Report Share Posted August 14, 2008 Kur tu tos koda gabalus ņem? $komsk=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM komentaari WHERE raksta_id='.$raksta_id.'")); Un pie izvades:$komsk['COUNT(*)'] Link to comment Share on other sites More sharing options...
sulik Posted August 14, 2008 Report Share Posted August 14, 2008 _fetch vietā var izmantot mysql_result; $komsk=mysql_query("SELECT COUNT(*) FROM komentaari WHERE raksta_id='.$raksta_id.'"); $komsk = @mysql_result($komsk); Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 (edited) sulik un kada izvade tavā variantā? duplet tavs variants noved pie errora Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\AppServ\www\index.php on line 122 sulik tavs variants noved pie tukšām iekavām varbūt palīdzēs viss kods <?php $result=mysql_query("SELECT id, virsraksts, raksts, laiks FROM jaunumi ORDER BY laiks DESC LIMIT 4 "); while($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<h3 class='news_title'>$row[1] </h3><br /> $row[2]<br /><br><strong>Pievienots: </strong>".date("d", $row[3])."/".date("m", $row[3])."/".date("Y", $row[3])." | <a href='komentaari.php?raksta_id=$row[0]'><strong>Komentāri (te komentāru skaits)</strong></a> <br /><br><br /><br><br>"; } ?> Edited August 14, 2008 by RaaapuLis Link to comment Share on other sites More sharing options...
duplets Posted August 14, 2008 Report Share Posted August 14, 2008 Mans variants ne pie kāda errora nenved, problēma, ir tur, ka nemāki viņu izmantot! Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 nu tad parādi kur kodā viņi jāliek? Link to comment Share on other sites More sharing options...
duplets Posted August 14, 2008 Report Share Posted August 14, 2008 (edited) echo "<h3 class='news_title'>...</h3><br /> <br /><br><strong>...</strong>DATUMS | <a href='...'><strong>Komentāri (".$komsk['COUNT(*)'].")</strong></a> <br /><br><br /><br><br>"; Kveri atsāj pirms šī te echo kkvai.. Edited August 14, 2008 by duplets Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 (edited) :D šī daļa man zināma man vajag to mysql daļu mēģinu visādus variantus te errors, te tukš, te rādās 0 komenti man leikas ka vaina ir raksta_id='.$raksta_id.' tur viss pareizs vispār? Edited August 14, 2008 by RaaapuLis Link to comment Share on other sites More sharing options...
Norek Posted August 14, 2008 Report Share Posted August 14, 2008 PHP <? $komsk =mysql_query("SELECT COUNT(*) FROM komentaari WHERE raksta_id='".$raksta_id."' "); ?> Link to comment Share on other sites More sharing options...
X ID Posted August 14, 2008 Report Share Posted August 14, 2008 SELECT id, virsraksts, raksts, laiks, COUNT(k.id) AS c FROM `jaunumi` j LEFT JOIN `komentari` k ON (k.raksta_id=j.id) GROUP BY j.id ORDER BY laiks DESC LIMIT 4 Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 nedarbojas iekavās rāda 0 PHP <?php $result =mysql_query("SELECT id, virsraksts, raksts, laiks FROM jaunumi ORDER BY laiks DESC LIMIT 4"); $komsk=mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM komentaari WHERE raksta_id='$raksta_id'")); while( $row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<h3 class='news_title'>$row[1] </h3><br /> $row[2]<br /><br><strong>Pievienots: </strong>".date("d", $row[3])."/".date("m", $row[3])."/".date("Y", $row[3])." | <a href='komentaari.php?raksta_id=$row[0]'><strong>Komentāri (".$komsk['COUNT(*)'].")</strong></a> <br /><br><br /><br><br>"; } ?> Link to comment Share on other sites More sharing options...
wap1337 Posted August 14, 2008 Report Share Posted August 14, 2008 gadījumā nevajag ."$row[1]"</h3><br /> Link to comment Share on other sites More sharing options...
X ID Posted August 14, 2008 Report Share Posted August 14, 2008 (edited) Tu pats seko līdz tam ko dari? Kā tev šķiet, kur rodas tāds $raksta_id un vai vispār ir radies? EDIT: wap1337 sēdi klusu, ja nezini. Edited August 14, 2008 by X ID Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 $raksta_id ir mysql datubaazes tabulaa, atkskjir komentaaru, kuram raksta vins pieder.. un jā es sekoju līdzi Link to comment Share on other sites More sharing options...
X ID Posted August 14, 2008 Report Share Posted August 14, 2008 (edited) LOL? Izvadi savu kveriju un paskaties vai raksta id tiek padots. P.S. Tu pat nesaprati manu jautājumu. EDIT: Ja nepamaniji es tev iedevu daudz labāku sql pieprasījumu. Edited August 14, 2008 by X ID Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 (edited) Uztaisiju šādi <?php $db_host = 'localhost'; $db_user = 'users'; $db_password = 'parole'; $db_name = 'jaunumi'; $connection = mysql_connect($db_host, $db_user, $db_password) or die("Kļūda pieslēdzoties MySQL"); mysql_select_db($db_name, $connection); mysql_query("SET NAMES utf8"); $result=mysql_query("SELECT * FROM komentaari"); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "ID :{$row['id']} <br>" . "Raksts : {$row['raksta_id']} <br>" . "Autors : {$row['niks']} <br>" . "Komentārs : {$row['komentaars']} <br><br>"; } ?> un izvada visu :/ 333 posts Edited August 14, 2008 by RaaapuLis Link to comment Share on other sites More sharing options...
X ID Posted August 14, 2008 Report Share Posted August 14, 2008 Nu un ko tu gaidiji? Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 14, 2008 Author Report Share Posted August 14, 2008 bet kapec tad nevar uztaisit iekavaas to skaitu? Link to comment Share on other sites More sharing options...
X ID Posted August 14, 2008 Report Share Posted August 14, 2008 Bļin, tu stulbs esi? Liec to selektu ciklā vai lieto manu selektu. Saproti latviski? Link to comment Share on other sites More sharing options...
wap1337 Posted August 14, 2008 Report Share Posted August 14, 2008 Ko tev nevar , visu var, ar count izvadi cik tev daudz komentāri iekš id'a un viss! Link to comment Share on other sites More sharing options...
Ownmen Posted August 14, 2008 Report Share Posted August 14, 2008 (edited) ak dievs juus esiet pilniigi aamuri??? Ko Tur var burties tajā kodā, ir 2 ļoti vienkāršas iespējas. Ja Tev vēl nesanāca dabūt to skaitu tas te būs 2 piemēri: 1. echo mysql_result(mysql_query("SELECT COUNT(*) FROM komentaari WHERE raksta_id = '$_GET['raksta_id']'"),0,'COUNT(*)'); //kur $_GET['raksta_id'] ir paņemts raksta id no address bar 2. Pastāv ļoti jauka f-ja mysql_num_rows echo mysql_num_rows(mysql_query("SELECT id FROM komentaari WHERE raksta_id = '$_GET['raksta_id']'")); Rakstīju uz ārtu roku bet abiem vajadzētu strādāt! Edited August 14, 2008 by Ownmen Link to comment Share on other sites More sharing options...
wap1337 Posted August 14, 2008 Report Share Posted August 14, 2008 Vot Rāpuli redzi ar count var , un 2 vēl vispār vieglāks jau ar iebūvētu nummerāciju! Link to comment Share on other sites More sharing options...
RaaapuLis Posted August 15, 2008 Author Report Share Posted August 15, 2008 1. sintakses kļūda 2. sintakses kļūda var redzēt ka uz ātru koru, tā arī neviens neatbildēja, vai var būt mysql_fetch iekš vēl viena mysql_fetch Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now