[英]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">×</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.