RaitisRR Posted January 25, 2007 Report Share Posted January 25, 2007 sveiki velos izdrtukat no DB txt un lai tas tiktu aplaust - atspogulota tik dalla no ta luk kur izvelku txt : <table width="100%" border="0"> <?php $result = mysql_query("SELECT * FROM phpbb_posts_text ORDER BY `post_id` DESC LIMIT 20 "); while ($row = mysql_fetch_assoc($result)) { ?> <td><b><a href="/phpBB2/viewtopic.php?t=<?php echo $row['post_id']; ?>"><?php echo $row['post_subject']; ?></a></b></td> <tr><td><?php echo $row['post_text']; ?></td></tr> <?php } ?> </table> vajg lai 'post_text' tiktu aplaust idrukati tik pars teikumi no txt ! ka lai to paveic ? Link to comment Share on other sites More sharing options...
bubu Posted January 25, 2007 Report Share Posted January 25, 2007 Kas ir teikums? Ja teikums beidzās ar punktu. Tad atrodi otro vai trešo punktu (strpos) un apgriez stringu (substr). Tad arī dabūsi divus vai trīs teikumus. Link to comment Share on other sites More sharing options...
RaitisRR Posted January 25, 2007 Author Report Share Posted January 25, 2007 nu a ka lai uztaisa piem ka atelo tik konkretu daudzumu ziimju ? vnk gribu lai index lapa izdruka jaunakos postus kas pievienoti bet lai no posta redzama tik maza dalla... Link to comment Share on other sites More sharing options...
RaitisRR Posted January 25, 2007 Author Report Share Posted January 25, 2007 Starpcitu ka lai uztaisa ta lai man izdrukajas txt tik ar konkretu ir piem no 1- 20 ? $result = mysql_query("SELECT * FROM phpbb_posts_text ORDER BY `post_id` DESC LIMIT 20 "); nu te vinsh sakarto pec id bet ka lai panak lai druka no 1 - 20 id ? Link to comment Share on other sites More sharing options...
bubu Posted January 25, 2007 Report Share Posted January 25, 2007 Nu a kā? Kā izvada tekstu? Ar echo! Nu tad echo arī attēlo tās vajadzīgās zīmes. Ierakstus selektējot no datubāzes, tiem var norādīt dažādus nosacījumus ar WHERE, kuriem tiem jāatbilst: SELECT * FROM table WHERE id >= 1 AND id <= 20 Turpmāk manuāļa jautājumus lasi manuālī: http://dev.mysql.com/doc/#manual Un apskati arī šo: http://php.lv/f/index.php?showtopic=6491 Un vēl - ja nelietosi komatus savos teikumos, lai varētu saprast, ko tu tur gribi īsti pateikt, tad tādi topiki ceļos uz drazu. Link to comment Share on other sites More sharing options...
RaitisRR Posted January 26, 2007 Author Report Share Posted January 26, 2007 bet varbut varetu lugt lai kadz parada paraugu ka to tasiit ... Link to comment Share on other sites More sharing options...
Kristabs Posted January 26, 2007 Report Share Posted January 26, 2007 <?php function sb($t,$len="100"){ if(strlen($t) > $len){ $t = substr($t,$len)."..."; } return $t; } $result = mysql_query("SELECT * FROM phpbb_posts_text ORDER BY `post_id` ASC LIMIT 20 "); while($row = mysql_fetch_array($result)){ echo sb($row['phpbb_posts_text']); } ?> Link to comment Share on other sites More sharing options...
RaitisRR Posted January 26, 2007 Author Report Share Posted January 26, 2007 Vai nu es ko nepareizi daru lai nu ka man nez kapec nedarbojas... vinsh druka ara zinas bet tas kas ir loti garas vinsh vnk neizdruka... man vajg lai izdruka bet nepilnigi tb atspogulo tik pusi no txt... Link to comment Share on other sites More sharing options...
andrisp Posted January 26, 2007 Report Share Posted January 26, 2007 Gan jau, ka nepareizi kaut ko dari ;) Link to comment Share on other sites More sharing options...
bubu Posted January 26, 2007 Report Share Posted January 26, 2007 Kristabs: kāda slima suņa pēc tu $len mainīgo padod kā stringu, ja reāli tas ir skaitlis un tu to izmanto skaitļu salīdzināšanā? Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 26, 2007 Report Share Posted January 26, 2007 (edited) Un vēl - ja nelietosi komatus savos teikumos, lai varētu saprast, ko tu tur gribi īsti pateikt, tad tādi topiki ceļos uz drazu. hm RaitisRR teikumaa truka tikai 1 komata ;) pirms BET.... ;) nu vel Rupja stila kljuuda 2 BET... NU un kas par to? Redzeeti sliktaaki.... edit: RaitisRR --> te Edited January 26, 2007 by Grey_Wolf Link to comment Share on other sites More sharing options...
bubu Posted January 26, 2007 Report Share Posted January 26, 2007 Grey_Wolf: nu nu - pirmajā postā trūkst 3 komati ("sveiki, kā", "no tā, lūk kur", "Vajag, lai"), bet nākamajā postā jau 4. Un aiznākamajā veseli 6! (un par vārdu sintantisku korektumu es pat nepiesējos ;) Link to comment Share on other sites More sharing options...
RaitisRR Posted January 26, 2007 Author Report Share Posted January 26, 2007 (edited) Mes tagad apspriezam manu pareizrasktibu ?Labi pacentishos rakstiit saprotamaak... nu luk kur ir code : <table width="100%" border="0"> <?php function sb($t,$len="100"){ if(strlen($t) > $len){ $t = substr($t,$len)."..."; } return $t; } $result = mysql_query("SELECT * FROM phpbb_posts_text ORDER BY `post_id` ASC LIMIT 20 "); while ($row = mysql_fetch_assoc($result)) { ?> <td><b><a href="/phpBB2/viewtopic.php?t=<?php echo $row['post_id']; ?>"><?php echo $row['post_subject']; ?></a></b></td> <tr><td><?php echo $row['post_text']; ?></td></tr> <?php } ?> </table> Tagad vinsh izdruka visum, bet nesaskiro pec post id :( ? Man vajg panaakt lai izdrukatu tik 3 pirmos teikumus no gara posta ! Edited January 26, 2007 by RaitisRR Link to comment Share on other sites More sharing options...
andrisp Posted January 26, 2007 Report Share Posted January 26, 2007 Ir: $t = substr($t,$len)."..."; Vajag: $t = substr($t, 0, $len)."..."; Link to comment Share on other sites More sharing options...
Val Posted January 26, 2007 Report Share Posted January 26, 2007 (edited) Varbūt izmanto to funkciju, kas kodā? (max 100 simbolus dabūsi) //tb 103 simbolus, kopā ar '...' :) //RaitisRR: tam substr tavā funkcijā nav no kā ņemt to stringu... Edited January 26, 2007 by Val Link to comment Share on other sites More sharing options...
Recommended Posts