Hi,
I have a mysql database storing snort/Demarc data. I am writing my own html front end to query the database, and all works quite well. I now need to refine it a bit and group all the attack signatures together from each unique source IP address. When it is displayed, I only want the source IP address displayed once and the other fields displayed below it. Here is my current script:
<?php
$db=mysql_connect("localhost", "database", "password");
mysql_select_db("Demarc",$db);
$query="select INET_NTOA(ip_src), INET_NTOA(ip_dst), sig_name, timestamp FROM ip
hdr, event, signature WHERE INET_NTOA(ip_dst) BETWEEN '111.111.111.111' AND
'111.111.222.222' && event.cid=iphdr.cid && event.signature=signature.sig_id ORDER BY
timestamp DESC";
$result=mysql_query($query);
$number=mysql_numrows($result);
$i=0;
while($i < $number) {
$ip_src=mysql_result($result,$i,"INET_NTOA(ip_src)");
$ip_dst=mysql_result($result,$i,"INET_NTOA(ip_dst)");
$signature=mysql_result($result,$i,"sig_name");
$timestamp=mysql_result($result,$i,"timestamp");
?>
<table border="2" bgcolor="#b1d2f3">
<tr>
<td>Source Address</td><td><? echo "$ip_src"?></td>
</tr>
<tr>
<td>Destination Address</td><td><? echo "$ip_dst"?></td>
</tr>
<tr>
<td>Attack Signature</td><td><? echo "$signature"?></td>
</tr>
<tr>
<td>Time</td><td><? echo "$timestamp"?></td>
</tr>
</table>
<?
$i++;
}
?>
Perhaps I just need another loop of some sort? Any help is appreciated.
-Robin