我需要一些脚本帮助,exemple here
他们是3张桌子:
网络
network_id
network_name
status
优惠
offer_id
offer_name
onetwork_id
status
list_ip
network
offer
在IP地址详细信息的索引页面中,我获得了网络ID和要约名称,
----选择一个网络和一个报价选择,添加一个IP母猪你能看到IP地址详细信息的结果----
我怎么得到:network_name网络(来自list_ip)= network_id(来自网络)
和
offer_name提供商(来自list_ip)= offer_id(来自优惠)
<?php
$get_last = mysqli_query($con, "SELECT*FROM list_ip WHERE ip LIKE '".$ip."'");
if (isset($_GET['remove']))
{
$remove =($_GET['remove']);
{
// Remove the category
mysqli_query($con,"DELETE FROM `list_ip` WHERE `id` = '$remove'");
}
}
while($l_ip = mysqli_fetch_array($get_last))
{
?>
<tr>
<td class="center" align="center"><img src="<?=$l_ip['flag'];?>" border="0"></td>
<td class="center"><?=$l_ip['network'];?></td>
<td class="center"><?=$l_ip['offer'];?></td>
<td class="center"><?=$l_ip['ip'];?></td>
<td class="center" style="border-right:1px #c0c0c0 solid"><?=$l_ip['date'];?></td>
<td class="center">
<a href="index.php?remove=<?=$l_ip['id'];?>" onclick="return confirm('Are you sure?');"> <button class="btn btn-danger btn-sm"><i class="fa fa-trash-o"></i> Delete</button></a>
</td>
<?php } ?>
答案 0 :(得分:0)
我认为你只需要在查询中使用join语句。
以下是您的问题的查询:
SELECT *
FROM list_ip
INNER JOIN networks ON networks.network_id=list_ip.network AND
INNER JOIN offers ON offers.offer_id=list_ip.offer;
请参考:SQL Join