Forum Moderators: coopster
Here is what I mean
currently
192.168.1.50 192.168.1.1 test_sig 01-25-2006
src_ip dst_ip sig_name date
The results should be below the column names
src_ip dst_ip
192.168.1.50 192.168.1.1 ect...
is there also a way to make them fit or show up under each column?
thanks so much for the help in advance
here is my code.
<table border="1" width="75%" cellpadding="2" cellspacing="2">
<th align="center">signature</th>
<th align="center">dst_ip</th>
<th align="center">src_ip</th>
<?
$host = "localhost";
$user = "#*$!x";
$pass = "xxxxx";
$dbname = "xxxxx";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
//Query that is being run
$query= "select * from signature where sig_name= '" . $_POST['IP'] . "'";
//this will try to spit out the previous sql query
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
//this is a line break before the spit output
while ($line = mysql_fetch_row($result) )
{
echo $line[0]."\t".$line[1]."\t".$line[2]."\t".$line[3]."\t".$line[4]."<br>";
}
?>
<table border="1" width="75%" cellpadding="2" cellspacing="2">
<tr>
<td align="center">signature</td>
<td align="center">dst_ip</td>
<td align="center">src_ip</td>
<td align="center">date</td>
</tr>
<?php<?
$host = "localhost";
$user = "#*$!x";
$pass = "#*$!xx";
$dbname = "xxxxx";$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
//Query that is being run
$query= "select * from signature where sig_name= '" . $_POST['IP'] . "'";
//this will try to spit out the previous sql query
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
//this is a line break before the spit outputwhile ($line = mysql_fetch_row($result) )
{
echo '<tr>';
echo '<td align="center">'.$line[0].'</td>';
echo '<td align="center">'.$line[1].'</td>';
echo '<td align="center">'.$line[2].'</td>';
echo '<td align="center">'.$line[3].'</td>';
echo '</tr>';
}?>
</table>
dc
I would put it this way:
while ($line = mysql_fetch_row($result) )
{
echo "<tr>";
echo "<td align=center>$line[0]</td>";
echo "<td align=center>$line[1]</td>";
echo "<td align=center>$line[2]</td>";
echo "<td align=center>$line[3]</td>";
echo "</tr>";
}
Does the difference make sense?
Habtom
they both do exactly the same thing
>> Does the difference make sense?
well just to confuse and clarify at the same time, I would do this
while ($line = mysql_fetch_row($result)) {
echo '<tr>';
echo '<td align="center">',$line[0],'</td>';
echo '<td align="center">',$line[1],'</td>';
echo '<td align="center">',$line[2],'</td>';
echo '<td align="center">',$line[3],'</td>';
echo '</tr>';
}
difference, this does not force the echo to concatenate the line before outputting it. I wouldn't use the double quoted version, again too much work before outputting and you should also put in the quotes around "center" as dc and I have.
more info on output
Benchmarking PHP text output [webmasterworld.com]
while ($line = mysql_fetch_row($result) )
{
echo "<tr>";
echo "<td align='center'>".$line[0]."</td>";
echo "<td align='center'>".$line[1]."</td>";
echo "<td align='center'>".$line[2]."</td>";
echo "<td align='center'>".$line[3]."</td>";
echo "</tr>";
}
Using an apostrophe to enclose "center" will prevent the need to escape your quotes.