Home
PHP
Application
Php Manual
Pictures
GuestBook
 
 
  Introduction Dlog Aprint SpTpl 
  Yap Xml2Array

 

 

 
 
 
Ex. index Quick Start Search box
Edit rows Callbacks Events
Advanced Form 
   

Basic Example

How to enable Yap as simple pager!

<?php
/*
* test1.php
* Module yap testing program 1
* $Header: d:/cvs/classistd/yap/test1.php,v 1.5 2003/11/12 22:23:25 Administrator Exp $
*/
// Include the msgbox class
include_once('CYapBox.php');
// the module itself
include_once('CYap.php');
// The session are required, start it
session_start('test');
/*
* Open the HTML page. The module make the html code to show the contents
* but not open or close the page. The caller must provide the requireq code
* to start and to close the page
*/
echo '<html><body>';
/*
* Sql statement to retrieve the data to show. Two statement are required. The first
* give the row to show, the second one allows to retrieve the number of rows
* returned by tre previous sql statement.
* Notice the 'where '. If you don't add condition (i.e 'where id>1'), you must add
* the 'where' without any other condition (the module append to it the condition
* that it get from the search box).
* If you add some conditional statement you must end the statement with 'and'
* (i.e '... where id>1 and ') to allow to append the required search patterns.
*/
$SelectQuery='select id, DEvent, errno, text, filename, line from dlog where ';
$SelectCount='select count(*) from dlog where ';
/*
* Start to prepare the parameters for the module
*/
//Db Connection parameters
$db_info=array('servername'     => 'localhost',
               
'dbname'         => 'log',
               
'user'           => 'root',
               
'password'       => '',
               
'selectquery'    => $SelectQuery,
               
'selectcount'    => $SelectCount,
               
/* field to use to order the rows
                * it must 'selected' from $SelectQuery
                */
               
'orderfield'     => 'id',
                
/* order A=upward, D=descending*/
               
'orderdirection' => 'A',
               
/* should the module open the connection
                * to the database? */
               
'needopendb'     => true        
               
);
// Don't show the search box
$Search_field=array();
// Fields to show for each row
$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'),
                  );

$Show_info=array('prefix' => 'tst1');
// I don't setup the detail mode, the add/modify/delete row functions
$Modify_info=array();

// new class istance
$p=new CYap($Search_field, $Show_field, $db_info, $Show_info, $Modify_info);
// Show it
$p->showpage();
echo
'</body></html>';
// That's all folk!
?>

 

Copyright © 2003-2009 Darvin Andrioli, last change 16/11/2003