【发布时间】:2017-05-25 20:53:24
【问题描述】:
您好,我在显示数据时需要考虑两个表格
Table:product_desc 有 product_id 和 product_name
我正在阅读的表格是user_table,我从那里阅读了product_id
我显示数据的代码:
$db = $registry->get('db');
$query = "SELECT * FROM " . DB_PREFIX . "user_table";
$data = $db->query($query);
//update
if ( $data->num_rows ) { ?>
<div class="">
<table class="table table-hover">
<thead>
<tr>
<th>SNo.</th>
<th>User Name</th>
<th>Product ID</th>
</tr>
</thead>
<tbody>
<?php $count = 1; ?>
<?php foreach($data->rows as $k => $v){ ?>
<tr>
<td><?php echo $count++ ?></td>
<td><?php echo $v['username']; ?></td>
<td><?php echo $v['product_id']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
我正在尝试实现一些可以显示表 product_desc 中的 product_name 以匹配表 user_table 的 product_id
查询如:SELECTproduct_name from product_desc where product_id = " .$product_id";
【问题讨论】: