Search code examples
phptexteditorsummernote

Can't assign value to summernote vue html editor from mysql db


Im using summernote vue html editor, I write some content in the editor then i save it in the Mysql DB, now when i retrieve the content from DB using php and echo it on summernote, the editor shows the test content only i can't assign image value with text, please give me some solution for this. My code:

Code to initialize summernote:

<!-- include jquery -->
  <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> 

  <!-- include libraries BS3 -->
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css" />
  <script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script>

  <!-- include summernote -->
  <link rel="stylesheet" href="summernote-develop/dist/summernote.css">
  <script type="text/javascript" src="summernote-develop/dist/summernote.js"></script>

  <script type="text/javascript">
    $(document).ready(function() {
      $('#contents').summernote({
        height: 200
      });

    });

  </script>

Code to retrieve data from db and assign it to summernote:

<?php 
                         $con =mysqli_query($conn,"SELECT * FROM tbl_content WHERE user_id= '".$pro_id."' ORDER BY pro_id ASC");                      


                      while($data1=mysqli_fetch_array($con)){ $fx= $data1['content'];   ?>  


    <textarea class="summernote" id="contents" title="Contents" name="name1" value="<?php echo $fx ;?>"></textarea>

     <?php } ?>

This is my db content :

Mysql DB Data

This is my result of summernote value:

Summernote Result Data


Solution

  • Finally i got answer

    To add below code to my summernote script.

    var postForm = function() { var content = $('textarea[name="name1"]').html($('#summernote').summernote('code')); }

    Now i get all data from DB.