Example 3

Enable the rows editing

This examples shows how enable quickly the row editing functions.

<?php
/*
* test3.php
* Module yap testing program 3 (detail mode e modify function
* $Header: d:/cvs/classistd/yap/test3.php,v 1.3 2003/11/13 22:24:25 Administrator Exp $
*/

include_once('CYapBox.php');
include_once(
'CYap.php');
session_start('prova');
echo
'<html><body>';
$SelectQuery='select id, DEvent, errno, text, filename, line from dlog where ';
$SelectCount='select count(*) from dlog where ';
//Parameters setup
//Db Connection
$db_info=array('servername'     => 'localhost',
               
'dbname'         => 'log',
               
'user'           => 'root',
               
'password'       => '',
               
'selectquery'    => $SelectQuery,
               
'selectcount'    => $SelectCount,
               
'orderfield'     => 'id',
               
'orderdirection' => 'A',
               
'NeedOpenDb'     => false
               
);
// Field to use to perform searchs
$Search_field=array(array('description' => 'Event Date',
                          
'fieldname'   => 'DEvent',
                          
'type'        => 'A',
                          
'size'        => 14,
                          
'useregex'   => 1 ),
                    array(
'description' => 'Error Code',
                          
'fieldname'   => 'errno',
                          
'type'        => 'N'),
                    );
// Fields to shows inside the table
$Show_field=array(array('fieldname' => 'id',
                        
'header'    => 'Id'),
                  array(
'fieldname' => 'DEvent',
                        
'header'    => 'Event Date'),
                  array(
'fieldname' => 'errno',
                        
'header'    => 'Error Code'),
                  array(
'fieldname' => 'text',
                        
'header'    => 'Description'),
                  );
// set to show the detail mode link
$Show_info=array('prefix' => 'tst31',
                 
// set to show the detail mode link
                 
'showdethref' => true,
                 
// choose the language
                 
'languagefile' => 'language.it',
                 );
// Enable the add/modify/delete row function.
// I don't set any callback function, so the link
// is enable on all roows
$Modify_info=array(
                 
'table' => 'dlog',
                 
'keyfield' => 'id',
                 
'showdelete' => true,
                 
'showmodify' => true,
                 
'showadd' => true,
                 );


$p=new CYap($Search_field, $Show_field, $db_info, $Show_info, $Modify_info);
$p->showpage();
echo
'</body></html>';
?>