Location: PHPKode > scripts > deadatagrid > deadatagrid/example3.php
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Example 3 Datagrid</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript" type="text/javascript" src="util.js"></script>
</head>
<body>
<?php
require 'datagrid.class.php';

//setting a database connection
require_once 'dbconfig.php';
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Connection to database failed: ' . mysql_error());
mysql_select_db(DB_NAME) or die ('select_db failed!');

$grid = new Datagrid($conn);
$grid->baselink = 'example3.php';

//set table or sql
$grid->setFrom('lang');

//find only 'E%'
//$grid->setWhere('name:E%');

//set hidden columns
//$grid->setColHidden('id,proc');

//add recno
$grid->setRowNumber('true');
$grid->setColWidth('5%','5%','5%','20%','10%','10%','10%','10%','10%','10%');
$grid->rowclick = '$rowclick=" onclick=\"alert(\'primary key: $key - $field ( id: $row[id], name: $row[name], path_img: $row[path_img], proc: $row[proc], lnk: $row[lnk], datum: $row[datum], func: $row[func], chk: $row[chk], click: $row[click] )\'); parseURL(\'$this->baselink?keyid$this->_grid=$field\')\";";';
//set columns type
$grid->setColType('proc',datagrid::TYPE_PERCENT);
$grid->setColType('path_img',datagrid::TYPE_IMAGE);
$grid->setColType('chk',datagrid::TYPE_CHECK);
//$grid->setColType('chk',datagrid::TYPE_CHECK,'Checked');
$grid->setColType('datum',datagrid::TYPE_DATE);
$grid->setColType('lnk',datagrid::TYPE_HREF);
$grid->setColType('click',datagrid::TYPE_ONCLICK);
$grid->setColType('func',datagrid::TYPE_FUNCTION,'NekaFunkcija');

//some function
function NekaFunkcija($par){return strrev($par);}

?>
<div style="visibility:hidden; background-color:white; border: 0px solid black;" id="h_t"></div>
<div id="h_d">
<strong>Sample grid with sort, paging, search, rownumber, hide column, formating column </strong>
<br><strong>Find country on 'e'</strong>
<br><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
   <thead>
      <tr>
         <?php echo $grid->getHeader();?>
      </tr>
   </thead>

   <tbody>
      <?php echo $grid->getRows();?>
   </tbody>

   <tfoot>
      <tr>
         <td colspan="99" align="center">
            <span id="navlinks"><?php echo $grid->getFoot();?></span>
         </td>
      </tr>
   </tfoot>
</table>
</div>
</body>
</html>
Return current item: deadatagrid