Using SQL Server with DataGrid

Discuss everything related to ApPHP DataGrid class. All versions. Any questions related to the ApPHP DataGrid developing or using should be posted to this forum.
Please, check out Knowledge Base first before you post a question.

Moderators: ne_moj, zewa, vadimako, ne_moj, zewa, vadimako

Forum rules
Posts are to be made in the relevant forum. Users are asked to read the forum descriptions before posting.
rick2164
Newbie
Newbie
Posts: 1
Joined: Nov 15th, '16, 20:50

Using SQL Server with DataGrid

Postby rick2164 » Nov 15th, '16, 21:09

Desperately trying to get a basic hello world sql server grid to appear. Just purchased the datagrid and it WON'T WORK. Please Please Please help.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name='keywords' content='php grid, php datagrid, php data grid, datagrid sample, datagrid php, datagrid, grid php, datagrid in php, data grid in php, free php grid, free php datagrid, pear datagrid, datagrid paging' />
<meta name='description' content='Advanced Power of PHP - using ApPHP DataGrid Pro for displaying some statistical data' />
<meta name="author" content="ApPHP Company - Advanced Power of PHP">
<meta name="generator" content="ApPHP DataGrid Pro">
<title>ApPHP DataGrid :: Sample #1-1 (code)</title>
</head>
<body style="padding:10px">

<?php

################################################################################
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling: |
## +---------------------------------------------------------------------------+
## *** define a relative (virtual) path to datagrid.class.php file
## *** (relatively to the current file)
## *** RELATIVE PATH ONLY ***
define ('DATAGRID_DIR', ''); /* Ex.: 'datagrid/' */
require_once(DATAGRID_DIR.'datagrid.class.php');

// includes database connection parameters
include_once('install/config.inc.php');

ob_start();
## *** set needed options
$debug_mode = true;
$messaging = true;
$unique_prefix = "f_";
$dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix);

$dg_encoding = 'utf8';
$dg_collation = 'utf8_unicode_ci';
$dgrid->SetEncoding($dg_encoding, $dg_collation);


## *** set data source with needed options
## *** put a primary key on the first place
$sql = 'Select schoolno,school From school';
$default_order = array("schoolno"=>"ASC");
$dgrid->DataSource("PDO", "sqlsrv", $DB_HOST, $DB_NAME, $DB_USER, $DB_PASS, $sql, $default_order);

$dg_caption = '<b>Innovakids Grid</b> - <a href=index.php>Back to Index</a>';
$dgrid->SetCaption($dg_caption);

## +---------------------------------------------------------------------------+
## | 6. View Mode Settings: |
## +---------------------------------------------------------------------------+
## *** set columns in view mode
//$dgrid->SetAutoColumnsInViewMode(true);
$vm_columns = array(
"schoolno" =>array("header"=>"School #", "type"=>"label", "width"=>"130px", "align"=>"left", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
"school" =>array("header"=>"School", "type"=>"label", "width"=>"130px", "align"=>"left", "wrap"=>"nowrap", "text_length"=>"-1", "case"=>"normal"),
);
$dgrid->SetColumnsInViewMode($vm_columns);



## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode settings: |
## +---------------------------------------------------------------------------+
## *** set settings for edit/details mode
$table_name = "school";
$primary_key = "schoolno";
$condition = "";
$dgrid->SetTableEdit($table_name, $primary_key, $condition);
$dgrid->SetAutoColumnsInEditMode(true);

## +---------------------------------------------------------------------------+
## | 8. Bind the DataGrid: |
## +---------------------------------------------------------------------------+
## *** set debug mode & messaging options
$dgrid->Bind();
ob_end_flush();

?>
</body>
</html>

administrator
Site Admin
Site Admin
Posts: 5992
Joined: Jan 7th, '09, 23:18
Contact:

Re: Using SQL Server with DataGrid

Postby administrator » Nov 17th, '16, 09:13



Return to “ApPHP DataGrid”