Results 1 to 5 of 5

Thread: How to make paragraph in my simple text editor

  1. #1
    Join Date
    May 2016
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default How to make paragraph in my simple text editor

    Hi, I created a small text editor for my website with my small knowledge. The problem is that each time I publish Something with it it does not show the new paragraph and puts all the text in the same paragraph. Someone can help me to make in a way that each time I press enter it makes a new paragraph? I only know php and a bit of javascript. I have no idea what I could do and what to search for it. Thanks. I'm a begginer so I need an simple language and explanation, I only know some php and javascript, slowly learning.
    Here is the code I did:
    PHP Code:
    <?php

    mb_language
    ('uni');
    mb_internal_encoding('UTF-8');

    if(isset(
    $_POST['submit']))
    {
    if(!empty(
    $_POST['titre'])&&!empty($_POST['message']))

    {
    $titre=$_POST['titre'];
    $message=$_POST['message'];
    $id=$_POST['id'];

    $query=mysql_query("INSERT INTO editor(id,titre, message) VALUES
    ('
    $id','$titre','$message')");
    if(
    $query)
    {
    $select=mysql_query("SELECT * FROM editor ORDER BY id DESC");

    while(
    $row=mysql_fetch_assoc($select))
    {
    echo 
    $row['titre']."<br><strong>".$row['message']."</strong><br>";
    }
    }

    }
    } else echo 
    "Vous devez saisir tout les champs pour pouvoir poster un commentaire";



    ?>

    <form method='POST' action='index.php' enctype="multipart/form-data" name="myform">
    <strong>Poster un texte</strong>
    <p></p>
    <p>titulo</p>
    <textarea name="titre" rows="2" cols="35"></textarea><br>
    <p>Texto</p>
    <textarea name="message" style="display:none;" rows="6" cols="35"></textarea><br>





    <br>


    <input type="submit" name="submit" value="Poster"">
    </form>



    <?php
    $getquery
    =mysql_query("SELECT * FROM editor  ORDER BY id DESC");
    $rows=mysql_fetch_assoc($getquery);
     do {
    ?>
     <div id="a" style="border:2px solid #a1a1a1;
    padding:3px 10px; 
    background:#f2d9f2;
    width:260px;
    border-radius:10px;
    text-decoration:no;"
     >
     
     
      <a href="newsarticle.php?id=<?php echo $rows['id'];?>" target="new"><?php echo $rows['titre'];?></a><br>
    <?php echo $rows['message'];?><br>
    </div><br>
     <?php } while($rows=mysql_fetch_assoc($getquery))
     
     
     
    ?>
    Last edited by magictouch; 06-04-2016 at 11:37 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,030
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    A basic textarea cannot interpret new lines as new paragraphs, so it sounds like you need to use JavaScript to interpret the keystrokes and insert markup on the fly.

    Try researching "JavaScript markup editor", "JavaScript WYSIWYG editor", "JavaScript rich text editor", and "JavaScript markdown editor". You'll find various plugins that you can test. Each behave differently and some are more feature-packed so it's up to you to decide what suits your needs best.

    From a personal perspective, I prefer TinyMCE for my Fast Edit and Fast Apps freebies. They all use a WYSIWYG editor that can support HTML markup, from basic bold and lists to tables and image uploads, etc. You can customise TinyMCE any way you like, making it more advanced or really basic. I use version 3.x due to custom PHP mods, although they're now on v4, which is much more modern looking and adapts better to responsive admin panels. TinyMCE is also bundled with popular CMS packages such as Joomla! so it's easier for clients and the people I train/work with to move from one application to another, without feeling like they have to learn something new each time
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    magictouch (06-06-2016)

  4. #3
    Join Date
    May 2016
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    hi, thanks for the answer. I know some of this editors, but a I dont have much knowledge I dont know always to use it. I created a wysiwyg file and it works well, the problem is I tried to store in the database and it did not work, so I have no idea how to do to put in the database the things I publish with my wysiwyg editor. Can you help me?
    Thank you.

  5. #4
    Join Date
    May 2016
    Posts
    12
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    I tryed this code with a php query to insert in the database but did not work:
    HTML Code:
    <html>
    <head>
    <script src="wysiwyg/wysiwyg.js"></script>
    </head>
    <body onLoad="iFrameOn();">
    <h2>My web application that intakes data from users</h2>
    <form action="my_parse_file.php" name="myform" id="myform" method="post">
    <p>Entry Title: <input name="title" id="title" type="text" size="80" maxlength="80" /></p>
    <p>Entry Body:<br>
    <div id="wysiwyg_cp" style="padding:8px; width:700px;">
      <input type="button" onClick="iBold()" value="B"> 
      <input type="button" onClick="iUnderline()" value="U">
      <input type="button" onClick="iItalic()" value="I">
      <input type="button" onClick="iFontSize()" value="Text Size">
      <input type="button" onClick="iForeColor()" value="Text Color">
      <input type="button" onClick="iHorizontalRule()" value="HR">
      <input type="button" onClick="iUnorderedList()" value="UL">
      <input type="button" onClick="iOrderedList()" value="OL">
      <input type="button" onClick="iLink()" value="Link">
      <input type="button" onClick="iUnLink()" value="UnLink">
      <input type="button" onClick="iImage()" value="Image">
    </div>
    <!-- Hide(but keep)your normal textarea and place in the iFrame replacement for it -->
    <textarea style="display:none;" name="myTextArea" id="myTextArea" cols="100" rows="14"></textarea>
    <iframe name="richTextField" id="richTextField" style="border:#000000 1px solid; width:700px; height:300px;"></iframe>
    <!-- End replacing your normal textarea -->
    </p>
    <br /><br /><input name="myBtn" type="button" value="Submit Data" onClick="javascript:submit_form();"/>
    </form>
    </body>
    </html>

    my_parse_file.php
    PHP Code:
    <?php 
    echo '<h2>You posted:</h2><hr />'$_POST['title'] . '<hr />' stripslashes($_POST['myTextArea']);
    ?>
    Last edited by keyboard; 06-06-2016 at 06:51 PM. Reason: Format: [php] and [html] tags

  6. #5
    Join Date
    Oct 2016
    Posts
    9
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    I know this doesn't necessarily solve your issue, but I personally believe that adding a Markdown editor might be your best option.

Similar Threads

  1. how to count and insert into database by month
    By lyter in forum MySQL and other databases
    Replies: 0
    Last Post: 03-19-2008, 07:36 AM
  2. Automaticlly insert to database what typed in search
    By allahverdi in forum MySQL and other databases
    Replies: 1
    Last Post: 08-12-2007, 03:16 PM
  3. how to read file and insert database
    By jr_yeo in forum MySQL and other databases
    Replies: 17
    Last Post: 08-14-2006, 09:01 AM
  4. chained select insert into database
    By rahaiffi in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 08-05-2006, 09:33 PM
  5. Insert row in a mysql Database
    By pavmoxo in forum PHP
    Replies: 2
    Last Post: 04-18-2006, 04:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •