Login   Register  
PHP Classes
elePHPant
Icontem

File: test2.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pali  >  Textable  >  test2.php  >  Download  
File: test2.php
Role: Example script
Content type: text/plain
Description: Sample file
Class: Textable
Manage data in text files like database tables
Author: By
Last change: Update
Date: 9 years ago
Size: 1,237 bytes
 

Contents

Class file image Download
<?php

include "textable.class.php";

$tc = new textable("data.dat");             //constructs object with filename and reads table to the memory

if (isset($_REQUEST['submit'])){
        
$data = array($_REQUEST['name'], $_REQUEST['mailaddress'], $_REQUEST['comment']);
        
$tc->insert($data);                 //write data to the memory table
          
$tc->save();                         //saving changes
}

?>

        <table><tr><td valign="top">
        <form method="post">
        <table>
        <tr><td align="right">Name:</td><td><input type="text" name="name"></td>
        <tr><td align="right">E-mail address:</td><td><input type="text" name="mailaddress"></td>
        <tr><td align="right" valign="top">Comment:</td><td><textarea name="comment"  rows="10" cols="20"> </textarea></td></tr>
        <tr><td></td><td><input type="submit" name="submit" value="Go"></td>
        </table>
        </form>
        </td>

        <td valign="top">
        <table border="1">
        <tr><td width="80"><b>User</b></td>
            <td width="100"><b>E-mai address</b></td>
            <td width="80"><b>Comment</b></td></tr>
            
<?php
foreach ($tc->table as $row){               //the memory table
    
print "<tr><td>".$row[0] ."</td><td>"$row[1]."</td><td>".$row[2]."</td></tr>" ;
     }
?>

        </table></td></table>