Jump to content

Recommended Posts

greetings guys

 

  I found this forum really good.last time i was having the same problem but it solved all is left to formate the out put.im taking few input from page and mean while it is displaying the out put below and i want to put the display below in a tubular format rite now it is not in tabular formate.

<?php
if(isset($_POST['check'])){
$check = $_POST['check'];
if($check == '1'){
$mac = $_POST['mac'];
$ip = $_POST['ip'];
$user = $_POST['user'];
$adate = $_POST['adate'];
$bdate = $_POST['bdate'];

$fh = fopen('ATT00012.txt','ab');
    fwrite($fh, "$mac $ip $user $adate $bdate |\n");


fclose($fh);
}
}
?>
<html>
<head>
<title>User Details</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FF9900">
<form name="subform" action="add.php" method="post">
<input type="hidden" name="check" value="1">
  <table width="364" border="1" align="center">
    <tr> 
      <td width="174"><div align="center"><font size="2"><strong><font face="Verdana, Arial, Helvetica, sans-serif">MAC 
          ADDRESS</font></strong></font></div></td>
      <td width="174"><div align="center"> 
          <INPUT type="text" name="mac">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center"><font size="2"><strong><font face="Verdana, Arial, Helvetica, sans-serif">IP 
          ADDRESS</font></strong></font></div></td>
      <td><div align="center"> 
          <INPUT type="text" name="ip">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center"><font size="2"><strong><font face="Verdana, Arial, Helvetica, sans-serif">USERNAME</font></strong></font></div></td>
      <td><div align="center"> 
          <INPUT type="text" name="user">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center"><font size="2"><strong><font face="Verdana, Arial, Helvetica, sans-serif">ACTIVATE 
          DATE</font></strong></font></div></td>
      <td><div align="center"> 
          <INPUT type="text" name="adate">
        </div></td>
    </tr>
    <tr> 
      <td><div align="center"><font size="2"><strong><font face="Verdana, Arial, Helvetica, sans-serif">BLOCK 
          DATE</font></strong></font></div></td>
      <td><div align="center"> 
          <INPUT type="text" name="bdate">
        </div></td>
    </tr>
    <tr> 
      <td colspan="2"><div align="center"> 
          <INPUT type="submit" name="submit" value="Submit">
        </div></td>
    </tr>
  </table>
</form>

<hr>
<br>
<?php

$fh = fopen('ATT00012.txt','rb');

for ($line = fgets($fh); ! feof($fh); $line = fgets($fh)) {

    $line = trim($line);

    $info = explode('|', $line);

    print '' . $info[0] . "<br><br>";

}

fclose($fh);


?>
<p> </p><p> </p></body>
</html>

 

here is the script all i want to know to formate the display which will appear below page which contains this info

 

# MAC ADDRESS 	   IPADDRESS	USERNAME	ACTIVTE DATE	BLOCK DATE|
00:06:5b:4a:20:a1  10.100.28.1  Rogers  comm.	 15/05/2007 | 
00:16:76:21:b0:91  10.100.28.2  Shaheer  khan   15/05/2007 |     
4c:00:10:60:cd:2e  10.100.28.3  Imaad           15/05/2007 |
00:08:02:d3:4a:ef  10.100.28.4  Hassan          15/05/2007 |
00:09:6b:38:91:0b  10.100.28.5  Hamza  bakaiy   15/05/2007 |    
00:c0:26:78:06:61  10.100.28.6  Farhan  fahim   15/05/2007 17/05/2007 |     
00:50:04:d6:fc:95  10.100.28.7  Aamir           15/05/2007 |

 

 

looking forward for your kind response.

 

  Regards

  Net_Spy

here is the correct formate from which the data will be read and write.

 

# MAC ADDRESS 	     IPADDRESS	USERNAME	 ACTIVTE DATE	      BLOCK DATE|
00:06:5b:4a:20:a1    10.100.28.1      Rogers  comm.	 15/05/2007 | 
00:16:76:21:b0:91    10.100.28.2      Shaheer  khan        15/05/2007 |     
4c:00:10:60:cd:2e    10.100.28.3      Imaad                   15/05/2007 |
00:08:02:d3:4a:ef     10.100.28.4     Hassan                  15/05/2007 |
00:09:6b:38:91:0b    10.100.28.5     Hamza  bakaiy         15/05/2007 |    
00:c0:26:78:06:61    10.100.28.6     Farhan  fahim          15/05/2007 |             17/05/2007 |     
00:50:04:d6:fc:95     10.100.28.7    Aamir                     15/05/2007 |

i want this file to be display in tabular form i mean in table.each must be in diffrent column im sure you guys get point what i mean.

 

Regards

  Net_Spy

fwrite($fh, "$mac $ip $user $adate $bdate |\n");

 

That implies that a space is the delimiter between data in each line.  If so, you can simply explode that line into separate array elements:

 

<?php
echo "<tr>";
$parts = explode(" ", $line[0]);
for ($x=0;$x<count($parts);$x++) {
    echo "<td>". $parts[$x]. "</td>";
}
echo "</tr>\n";
?>[code]

[/code]

thankz AndyB for your reply..

 

  but i could get your point cause im noob in php :).i could not figure out where to modify and add these lines to be honest.im sure it will resovle my issue and display the output in tabular form being within same page i can add info and at the same time it will be displaying the result below in tabular.

 

 

  Regards

  Net_Spy

In your code, change

$fh = fopen('ATT00012.txt','rb');
for ($line = fgets($fh); ! feof($fh); $line = fgets($fh)) {
    $line = trim($line);
    $info = explode('|', $line);
    print '' . $info[0] . "<br><br>";
}
fclose($fh);

 

to:

echo "<table>":
$fh = fopen('ATT00012.txt','rb');
for ($line = fgets($fh); ! feof($fh); $line = fgets($fh)) {
    $line = trim($line);
    $info = explode('|', $line);
    echo "<tr>";
    $parts = explode(" ", $info[0]);
    for ($x=0;$x<count($parts);$x++) {
        echo "<td>". $parts[$x]. "</td>";
    }
    echo "</tr>\n";
}

fclose($fh);
echo "</table>";

thanks for your response

 

  well i did as you said to me but im getting this error message afte modification

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\test\test.php on line 75

im looking for your kind response.

 

  Regards

  Net_Spy

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.