部分代码:
<!-- this table is show all info in database -->
<table class="altrowstable" id="alternatecolor">
<tr>
<th style="width: 160px;">ID</th>
<th style="width: 160px;">IP</th>
</tr>
<?php
$id=0;
if (isset($_GET["id"]))
{
$id=intval($_GET["id"]);
}
if ($id==0)
{
die(0);
}
require("config.php");
try {
$dbh = new PDO($g_dsn, $g_user, $g_pass);
} catch (PDOException $e)
{
echo 'Connection failed: ' . $e->getMessage();
}
$uid=$_SESSION['userid'];
$dbh->query("use liwei;");
foreach ($dbh->query("SELECT * FROM iplist where uid=$uid and ipinfo_id=.$id;") as $row)
{
?>
<tr>
<td style="width: 160px;"><?= $row['id'] ?></td>
<td style="width: 160px;"><?= $row['ip'] ?></td>
</tr>
<?php
}
?>
</table>
数据库信息:
mysql> SELECT * FROM iplist where uid=0 and ipinfo_id=3;
+----+-----+-----------+----------------+------+------+
| id | uid | ipinfo_id | ip | pos | addr |
+----+-----+-----------+----------------+------+------+
| 1 | 0 | 3 | 101.226.65.104 | NULL | NULL |
| 2 | 0 | 3 | 59.53.67.207 | NULL | NULL |
| 6 | 0 | 3 | 61.159.117.78 | NULL | NULL |
+----+-----+-----------+----------------+------+------+
3 rows in set (0.00 sec)收起
坏境:php 7.1 mysql5.6 nginx1.12 centos7
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。