我的代码结果如下(前十名):
Country1 24
Country2 18
Country3 15
Country4 11
Country5 10
Country6 9
Country7 9
Country8 5
Country9 2
Country10 1
当我点击countryN时,我想显示一个包含所点击国家/地区的IP地址的模式。
<?php
$black="SELECT country,count(country) as number from bl where country!='NULL' group by country order by number desc limit 10";
$sql=mysql_query($black);
?>
<form action="" method="POST">
<table id="example" class="table table-striped" cellspacing="0" width="50%">
<?php
if (mysql_num_rows($sql)!=0)
{
while($result=mysql_fetch_array($sql))
{
echo ("<tr>");
echo ("<td><div align=\"center\"><a href='#openModal' name='modal'><img name='img' src=../Include/flag/".strtolower($result["country"]).".gif></a></div></td>");
echo("<td ><span class='badge'>".$result["number"]."</span></td>");
echo ("</tr>");
if (modal==true)
{
$bl="SELECT * from bl where country='".$result['country']."'";
$bl_res=mysql_query($bl);
?>
<div id="openModal" class="modalDialog">
<div>
<a href="#close" title="Close" class="close">X</a>
<h2>Blacklist details</h2>
<?php
while ($row=mysql_fetch_array($bl_res))
{
echo $row['timestamp']." ".$row['ip']." ".$row['sensor']."<br>";
}
?>
</div>
</div>
<?php
}
}
}
?>
问题在于,当我点击任何国家/地区时,它会显示country1的IP地址。