TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   need to show data in other html table for php (http://forums.techarena.in/software-development/1207104.htm)

Quattro 02-07-2009 11:36 PM

need to show data in other html table for php
 
Hi,

I have a form in php & the details get stored in a text file.
I want these details to get stored & then to be displayed in another webpage in a table.
I am not sure if I could do this in php.
If you can help me out it will be great.
Your suggestions are most welcome.

rupak 02-07-2009 11:37 PM

Re: need to show data in other html table for php
 
Try this:

Code:

<?

      $data=file_get_contents('filename.txt'); //get data from file

      $dat=explode("\r\n",$data); //split data at new lines

      echo '<table border=1 cellpadding=3 cellspacing=0>';

      foreach ($dat AS $val) { //loop

      echo '<tr><td>'.$val.'</td></tr>'; //display

      }

      echo '</table>';

      ?>

I hope this is what you need.

Darth 02-07-2009 11:42 PM

Re: need to show data in other html table for php
 
I have a question regarding display of data in php table in corresponding table & respective columns & I am really dont have any idea if its possible for me.
If you have any idea to display mysql data on php table please help[ me out with the code.
Thanks in advance

Gap meer 02-07-2009 11:44 PM

Re: need to show data in other html table for php
 
Try this code:
Code:

<table border="2" width="75%" cellpadding="3" cellspacing="3">
<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 output

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>';
}

?>
</table>



All times are GMT +5.5. The time now is 06:14 PM.