我试图用我的表中的数据填充我的模态文本框,但我无法使它工作

我试图用我的表中的数据填充我的模态文本框,但我无法使它工作

问题描述:

我对这种网络开发有点新东西,我正在使用bootstrap。我试图用我的表中的数据填充我的模态文本框,但我无法使它工作

这里是我的表:

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

嗨感谢您的答复,对不起,我没有意识到我把它放在那里。虽然没有改变任何东西。 – user3425377