你好我的第一个问题,我很难让这段代码工作或者更好地说明如何继续。
我有2个表,表1包含一个用逗号分隔的字符串,在爆炸数组后我想将字符串与另一个包含与字符串相关的产品价格的表进行比较。
<?php
function packages()
{
global $db;
$query = "SELECT * FROM product_package WHERE package_id > 1; ";
$result = mysqli_query($db, $query) or die('<h3>Query failed</h3>');
$rowcount = mysqli_num_rows($result);
if ($rowcount < 1)
{
return;
}
else
{
while ($row = mysqli_fetch_array($result))
{
$singles = explode(',', $row["product_ids"]);
$query2 = "SELECT product_price FROM products WHERE product_id = $single; ";
$result2 = mysqli_query($db, $query2);
?>
<tr>
<td><?php echo $row["package_id"] ?></td>
<td><?php echo $row["package_name"] ?></td>
<td><?php echo $row["product_ids"] ?></td>
<td>
<a href="package_edit.php?product_id=<?php echo $row["package_id"] ?>">EDIT</a>
</td>
<td>
<?php
foreach($singles as $single)
{
echo $single . '<br />';
}
?>
</td>
</tr>
<?php
}
}
}
?>
如何回显与$single
重叠的价格?