0

I am having difficulties to display the content of a db field into a php form field. This is part of the php that queries the db:

    <!DOCTYPE html>
    <?php
            include '../sys/conn.php';
            $risultato = mysqli_query ($conn, "

            SELECT 
                 p.id as ID, 
                 p.post_title, 
                 p.post_excerpt as shortdesc, 
                 p.post_content as longdesc
                 FROM mg_posts as p
                 LEFT JOIN mg_term_relationships as r ON r.object_id=p.id
                 JOIN mg_term_taxonomy as t ON t.term_taxonomy_id=r.term_taxonomy_id
                 JOIN mg_terms as tr ON tr.term_id=t.term_id
                 JOIN mg_postmeta pm ON (pm.post_id = p.ID)
                 WHERE p.ID= 13323
                 GROUP BY p.ID

                 ") or die ("Query non valida: " . mysqli_error($conn));
                 mysqli_close($conn);
                 $row = mysqli_fetch_array($risultato);
?>

    <body>
        .....

          <div class="col-lg-12">
          <form role="form">

            <div class="form-group">
            <label>Short Desc</label>
            <textarea class="form-control" value = "<?php echo $row['shortdesc']; ?>" >   
            </textarea>
            </div>

           <div class="form-group">
           <label>LongDesc</label>
           <textarea class="form-control" value = "<?php echo $row['longdesc']; ?>" >       
           </textarea>

        </div>
        </div>

        ......
        </body>
        </html>

I cannot understand why 'longdesc' in the form displays correctly the content while the 'shortdesc' displays only a white field.

Any idea?

2
  • 2
    You tried above query in MySQL and it does have shortdesc?? or is it NULL/ empty? Commented Aug 13, 2017 at 10:55
  • yes sure --> select p.id, p.post_excerpt, p.post_content from mg_posts p where p.id=13323 13323 <strong>Sostanze funzionali:</strong> Glicerina bi... <div class="subt_itemdesc">Cosa rende speciale la ... <--- Commented Aug 13, 2017 at 11:10

1 Answer 1

2

So for textarea, instead of assigning value, you should do it like this, because it doesn't really have a value attribute. You can read here more on various attributes that textarea have:

<textarea class="form-control"><?php echo $row['shortdesc']; ?></textarea>

The same will apply for your longdesc too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.