简体   繁体   English

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

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

I am new to this web development kind of thing, I'm using bootstrap. 我是这种Web开发的新手,我正在使用引导程序。

Here is my table: 这是我的桌子:

    <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>

I'm trying to call the modal on that last td tag right there. 我正在尝试在那最后一个td标签上调用模式。

Here is my modal: 这是我的模态:

<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>

Now, if I can just echo that product name on that textbox right there, it will be fine. 现在,如果我可以在那个文本框中回显该产品名称,那就很好了。 But I haven't achieved it till now. 但是直到现在我还没有实现。

In html if you want the input to have a value inside of it you give it a "value". 在html中,如果您希望输入中包含一个值,则可以给它一个“值”。

So it would be 原来如此

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

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

相关问题 我正在尝试使用列数创建动态表,但是我无法从sql查询中获取列数 - I'm trying make a dynamic table with a column count, but I can't get the column count out of my sql query 如何填充文本框? - How do I populate my textboxes? 当我尝试在列表视图上显示来自 MYSQL 数据库的数据时,我的 Flutter 代码有点错误 - I have a little wrong in my Flutter code while i'm trying to display datas from MYSQL database on List View 我正在尝试将PDO和OOP结合起来,但无法使其正常工作 - I'm trying to combine PDO and OOP, and can't get it to work 为什么我无法从桌子上获得参数? - Why I can't get param from my table? 我正在尝试在表中显示数据库中的数据,但不想出现,也不知道出了什么问题 - I'm trying to display data from my database in table, but don't want to appear, I don't know what went wrong 我正在尝试将数据从MySQL显示到包含表格的PHP页面,但我无法在表格中显示信息 - I'm trying to display data from MySQL onto a PHP page that contains a table but I can't get the info to display inside the table 我无法让我的jquery在我的wordpress网站上工作 - I can't get my jquery to work in my wordpress site 我无法为我的画廊图像获取模态框 - i'm not able to get modal box for my gallery images 由于某种原因,我在我的一个文本框中收到通知 - I'm getting a notice in 1 of my textboxes for some reason
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM