2015-04-12 87 views
0

我對這種網絡開發有點新東西,我正在使用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> 

現在,如果我可以附和該產品名稱出現在文本框在那裏,會被罰款。但直到現在我還沒有實現。

回答

0

在html中,如果您希望輸入內有一個值,您可以給它一個「值」。

因此,這將是

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

嗨感謝您的答覆,對不起,我沒有意識到我把它放在那裏。雖然沒有改變任何東西。 – user3425377

相關問題