edi Posted May 18, 2010 Report Share Posted May 18, 2010 (edited) tatad izvadu textarea tekstu no datubazes un textarea lauka izvadas <br /> tegi. ka vinus aizstaj ar jaunu rindu? Edited May 18, 2010 by edi Quote Link to comment Share on other sites More sharing options...
ohmygod Posted May 18, 2010 Report Share Posted May 18, 2010 (edited) <?php function nl2br_revert($string) { return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); } ?> php.net pirmais useru posts pie nl2br Edited May 18, 2010 by ohmygod Quote Link to comment Share on other sites More sharing options...
edi Posted May 18, 2010 Author Report Share Posted May 18, 2010 <?php function nl2br_revert($string) { return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string); } ?> php.net pirmais useru posts pie nl2br es jau meginaju, nepalidz Quote Link to comment Share on other sites More sharing options...
ohmygod Posted May 18, 2010 Report Share Posted May 18, 2010 tā nevarētu būt. Būs vien jārāda, ko atdod db pēc pieprasījuma. Quote Link to comment Share on other sites More sharing options...
edi Posted May 18, 2010 Author Report Share Posted May 18, 2010 (edited) tā nevarētu būt. Būs vien jārāda, ko atdod db pēc pieprasījuma. $text = mysql_result(mysql_query("SELECT `text` FROM `table` WHERE `id`='$id' AND `author`='$login';"),0); // iegutais teksts = bla bla bla bla<br />blablabla<br />bla bla bla<br />bla bla<br />blabla bla echo '<textarea name="msg" cols="70" rows="15"/>'.nl2br_revert($text).'</textarea><br/>'; man liekas ta f-ja nav pareiza un kas tas par $1, kas aizstaj <br> izmantojot f-ju nekas nenotiek :D meginaju vienkasi ar str_replace('<br />', '$1',$text) $1 paradijas un tas ari viss :) Edited May 18, 2010 by edi Quote Link to comment Share on other sites More sharing options...
ohmygod Posted May 18, 2010 Report Share Posted May 18, 2010 Nu paņem tak kaut visvienkāršāko str_replace('<br />', "\n", $text); Quote Link to comment Share on other sites More sharing options...
edi Posted May 18, 2010 Author Report Share Posted May 18, 2010 (edited) Nu paņem tak kaut visvienkāršāko str_replace('<br />', "\n", $text); es jau meginaju, nekas nesanak! vienkasi izvada ka tekstu nevis ka jaunu rindu. Edited May 18, 2010 by edi Quote Link to comment Share on other sites More sharing options...
ohmygod Posted May 18, 2010 Report Share Posted May 18, 2010 tu tiešām liec newline, nevis \n? ir atšķirība vai '\n' vai "\n" Quote Link to comment Share on other sites More sharing options...
briedis Posted May 18, 2010 Report Share Posted May 18, 2010 (edited) Varu saderēt, ka tie <br> patiesībā ir <br> Vienmēr vajag skatīties ko rāda pārlūka source, nevis to, ko redzi, kad jau pārlūks ir norenderējis... Vispirms var mēģināt htmlspecialchars_decode un tad nl2br_rever, vai kā tur... Edited May 18, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
edi Posted May 18, 2010 Author Report Share Posted May 18, 2010 Varu saderēt, ka tie <br> patiesībā ir <br> Vienmēr vajag skatīties ko rāda pārlūka source, nevis to, ko redzi, kad jau pārlūks ir norenderējis... Vispirms var mēģināt htmlspecialchars_decode un tad nl2br_rever, vai kā tur... ne ir <br /> nevis <br> Quote Link to comment Share on other sites More sharing options...
ohmygod Posted May 18, 2010 Report Share Posted May 18, 2010 iekš textarea jau rādītos < nevis <, ja tāds tiktu padots. Quote Link to comment Share on other sites More sharing options...
edi Posted May 18, 2010 Author Report Share Posted May 18, 2010 (edited) <form action="" method="POST"/><textarea name="msg" cols="70" rows="15"/>bal bla bla lba bla bal<br />bla bla <br />blabla<br />blabal<br />blabla<br />bla<br />bal<br />bal</textarea><br/><input type="submit" name="submit" value="Labot"/></form> rekur source kods no brauzera Edited May 18, 2010 by edi Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted May 18, 2010 Report Share Posted May 18, 2010 Laikam jau ir stilīgi katru tagu aizvērt uzreiz ciet. Iesaku palasīt par HTML un XML. hint : <tag></tag> == <tag /> Quote Link to comment Share on other sites More sharing options...
edi Posted May 19, 2010 Author Report Share Posted May 19, 2010 Laikam jau ir stilīgi katru tagu aizvērt uzreiz ciet. Iesaku palasīt par HTML un XML. hint : <tag></tag> == <tag /> man liekas brauzerim ir pilnigi vienalga vai tas slash ir pie tas formas vai nav, bet tas tapat nepalidzes :D man liekas, ka ar javascript vajag to visu apstradat Quote Link to comment Share on other sites More sharing options...
Pentiums Posted May 19, 2010 Report Share Posted May 19, 2010 glabā datubāzē nevis ar br bet ar newlines Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.