简体   繁体   中英

How To Display Multiple Value From Table Mysql To Textarea Field With Looping Php

I have a 2 value in my DB

+--------------+------------------+-----------+
|    id_des    |     deskripsi    |   id_srt  |
+--------------+------------------+-----------+
|      1       |       Test 4     |     4     |
|      2       |       Test 2     |     4     |
+--------------+------------------+-----------+

I want to display the deskripsi value where id_srt = '4' to my textarea field (sample)

But they are not visible when I run the script:

在此处输入图片说明

As you can see, the textarea field isn't visible.

Here is my code:

<?php
$id = isset ($_POST['id_srt']);
$sql = "SELECT * FROM deskripsisrt WHERE id_des = '$id'";
$result = mysqli_query ($con,$sql);
while ($row = mysqli_fetch_array($result)){
    ?> 
    </br>
    <a href="#" style=\"color:#EC090D; cursor:pointer; text-align: Right;\" onclick="hapusElemen(\'#srow' + desc + '\'); return false;">hapus</a>
    <div class="input-group">
        <textarea rows="6" cols="100" type="text" class="desce form-control" name="deskripsi[]" id="deskripsi" placeholder="deskripsi" size="100"><?php echo $row ['deskripsi']; ?>
        </textarea>
    </br>
    </div>
    <?php
}?>

So my question how to display a multiple value on textarea ?

将您的SQL查询更改为

$sql = "SELECT * FROM deskripsisrt WHERE id_srt = '$id'";

So after editing my code i found a problem in here

$id = isset ($_POST['id_srt']);

The $id never get valu from input field,.. So anybody can help me to fix my code to get value $id ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM