【发布时间】:2021-09-12 05:13:56
【问题描述】:
我刚刚创建了一个从 wordpress 数据库中收集值的数据表。- 这些值必须加载到模态中的联系表单中。我从数据表每一行的最后一列中的按钮调用模式。 我必须用每一行对应的信息预先确定表单字段的值。 示例:我单击第 3 行中的按钮,它应该打开带有表单的模式,并且已经用第 3 行中的信息填写的字段
我的问题是它不会那样发生。 如果我随机单击按钮,它会以 row1、row2、row3 等的顺序加载模式和表单以及数据。 示例:如果我单击第 1 行中的按钮,它将打开带有表单和第 1 行数据的模式 但是如果我然后单击按钮 5,它会打开第 2 行的信息(它应该加载我第 5 行的信息) 如果然后我给第 8 行(或任何其他)的按钮,它会加载我第 3 行的信息 等等
如果有人能告诉我问题出在哪里或给我另一个解决方案来加载每个表单中每一行的数据
php代码
<table id="enquire" class="display" style="width:100%">
<thead>
<tr>
<th>Id</th>
<th>part</th>
<th>code</th>
<th>manufacturer</th>
<th>datanumber</th>
<th></th>
</tr>
</thead>
<tbody>
<?php global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM client" );
foreach ( $result as $print ) {?>
<tr>
<td><?php echo $print->id;?></td>
<td><?php echo $print->part;?></td>
<td><?php echo $print->code;?></td>
<td><?php echo $print->manufacturer;?></td>
<td><?php echo $print->datanumber;?></td>
<td><button class="uk-button" type="button" uk-toggle="target: #modal">ENQUIRE NOW</button></td>
</tr>
<?php }?>
</tbody>
<tfoot>
<tr>
<th>Id</th>
<th>part</th>
<th>code</th>
<th>manufacturer</th>
<th>datanumber</th>
<th></th>
</tr>
</tfoot>
</table>
模态
<div id="modal" uk-modal>
<div class="uk-modal-dialog uk-modal-body">
<button class="uk-modal-close-default" type="button" uk-close></button>
<?php include('form.php');?>
</div>
</div>
表格
<form>
<fieldset class="uk-fieldset">
<legend class="uk-legend">Form</legend>
<div class="uk-margin">
<input class="uk-input" type="text" value="<?php echo $print->id;?>" placeholder="id">
</div>
<div class="uk-margin">
<input class="uk-input" type="text" value="<?php echo $print->part;?>" placeholder="part">
</div>
<div class="uk-margin">
<textarea class="uk-textarea" rows="5" placeholder="Textarea"><?php echo $print->manufacturer;?></textarea>
</div>
</fieldset>
</form>
【问题讨论】:
标签: php html mysql forms datatable