繁体   English   中英

我正在尝试使用表格中的数据填充模式文本框,但无法正常工作

[英]I'm trying to populate my modal textboxes with datas from my table but i can't get it to work

我是这种Web开发的新手,我正在使用引导程序。

这是我的桌子:

    <table class="table table-striped table-bordered">
        <thead>
            <tr>
                <th style="text-align:center;"> ITEM CODE </th>
                <th style="text-align:center;"> SIZE </th>
                <th style="text-align:center;"> COLOR </th>
                <th style="text-align:center;"> ACTION </th>
            </tr>
        </thead>
        <tbody>
        <?php
            include('connect.php');
            $result = mysql_query("SELECT * FROM products");
            while($row = mysql_fetch_array($result))
                {
                    echo '<tr>';
                    echo '<td style="text-align:center;">'.$row['itemcode'].'</td>';
                    echo '<td style="text-align:center;">'.$row['size'].'</td>';
                    echo '<td style="text-align:center;">'.$row['color'].'</td>';
                    echo '<td style="text-align:center;"><a data-toggle="modal" data-target="#editProductsModal" href="#?itemcode='.$row['itemcode'].'&size='.$row['size'].'&color='.$row['color'].'">edit</a></td>';
                    echo '</tr>';
                }

            ?> 
        </tbody>
    </table>

我正在尝试在那最后一个td标签上调用模式。

这是我的模态:

<div class="modal fade" id="editProductsModal" tabindex="-1" role="dialog" aria-labelledby="largeModal" aria-hidden="true">


 <?php
include('connect.php');
$itemcode=$_GET['itemcode'];
$size=$_GET['size'];
$color=$_GET['color'];
$result = mysql_query("SELECT * FROM products where itemcode='$itemcode' and size='$size' and color='$color'");
    while($row = mysql_fetch_array($result))
        {
        $name=$row['name'];
        }
?>



 <div class="modal-dialog modal-sm">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h1 class="modal-title" id="myModalLabel">Edit Products</h1>
      </div>
      <div class="modal-body">
        <input type="text" class="form-control input-sm" placeholder="Product name" value="<?php echo $name;?>"></input>
      </div>
      <div class="modal-footer">
        <a href="execEditProduct.php" class="btn btn-primary btn-lg">DO IT!</a>
      </div>
    </div>
  </div>
</div>

现在,如果我可以在那个文本框中回显该产品名称,那就很好了。 但是直到现在我还没有实现。

在html中,如果您希望输入中包含一个值,则可以给它一个“值”。

原来如此

<input type.... value=<?php echo $name ?></input>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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