3.2.0

Grid does not show in table (PHP)

I have tried using both the V1 and V2 of the Grid control (which I think is awesome by the way) and it seems to work fine when doing my own stub examples. However, when trying to put a Grid into a page in my project it just won't show. Any help would be greatly appreciated.

++++++++++++++++++++++++++++++++++++++++++++
<?php
//////////////////////////////////////////////////////////////////
// FILE: payee_srch.php .
// CREATED: 9/11/04 .
//////////////////////////////////////////////////////////////////
error_reporting(0);
ob_start();
session_start(); // Initialise the session
$expireTime = 60; // 1 minute
session_set_cookie_params($expireTime * 30);

$outUser = $_SESSION['usrname'];
$outPswd = $_SESSION['usrpswd'];
$outLang = $_SESSION['usrlang'];
$outProv = $_SESSION['usrprov'];
$LoginOK = $_SESSION['loginok'];

If ($LoginOK) {
// Include Database Functions
include 'ev_db.php';

// Include Field Functions
include 'ev_flds.php';

$outOrigPg = "payee_srch.php";

// Define the Page TITLE section
$outPageId = "h0";
include 'ev_ttl.php';

// ActiveWidgets PHP functions
$query = "SELCT pmsCompName, pmsAcctNum, pmsCompCity from payeemast ORDER BY pmsCompName";
include 'grid.php';

// Display the Page Header
include 'ev_hdr.php';

// Display the menu
$outPageId = "m0";
include 'ev_mnu.php';

// Set Page Language Variable
$outPageId = "p6";
$noPayees = 'N';
// Get Field Labels
$arField = getFields($outPageId, '', $outLang, True, 18);

?>
<form action="" onSubmit="" onReset="">
<table class="evPageBODY" cellspacing="1" cellPadding="2" width="100%" border="1">
<tr valign="top">
<td>
<H2><?php echo $arField[0]; ?></H2>
</td>
</tr>
<tr valign="top">
<td>
<table class="evPageBODY" cellspacing="1" cellPadding="2" width="100%" border="0">
<tr>
<td align="left" colspan="2">
<?php echo $arField[1]; ?>
&nbsp;&nbsp;
<input type="text" name="search" value="" size="50" maxlength="255">
</td>
</tr>
<tr>
<td align="left" colspan="2"
<?php
if ($noPayees == 'Y') {
echo " bgcolor='#FFFF40'>This Payee was not found in our list. To continue please add this Payee.";
} else {
echo ">";
}
?>
<input type="Submit" value='<?php echo $arField[2]; ?>'>&nbsp;&nbsp;&nbsp;<input type="Reset" value=' <?php echo $arField[3]; ?> '>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<?php

// grid object name
$name = "obj";

// SQL query
$query = "select pmsCompName, pmsCompAddr1, pmsCompCity, pmsCompProv, pmsCompWeb from payeemast";

// database connection
$connection = mysql_connect("localhost", "wklapwyk", "cavalier");
mysql_select_db("evault");

// query results
$data = mysql_query($query, $connection);

// add grid to the page
echo activewidgets_grid($name, $data);
?>
</td>
</tr>
</table>
</td
</tr>
</table>
</form>

<?php
include "ev_ftr.php";
?>
++++++++++++++++++++++++++++++++++++++++++++
<?php
//////////////////////////////////////////////////////////////////
// FILE: ev_ttl.php .
// CREATED: 10/03/04 .
//////////////////////////////////////////////////////////////////

// Get Field Labels
$arField = getFields($outPageId, 't001', $outLang, False, 1);

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>eVault - <?php echo $arField[0]; ?></title>
<meta http-equiv="content-type"content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="Themes/Style.css"></link>
<link rel="stylesheet" type="text/css" href="Themes/CascadeMenu.css"></link>
<!-- ActiveWidgets stylesheet and scripts -->
<link rel="stylesheet" type="text/css" href="Themes/ev/xp/aw.css"></link>
<script language="javascript" src="js/aw.js"></script>
<!-- Menu Stylesheet -->
<script language="javascript" src="js/CascadeMenu.js"></script>
++++++++++++++++++++++++++++++++++++++++++++
<?php

/*
include this file into your PHP page
usage example:
*/

/*
// grid object name
$name = "obj";

// SQL query
$query = "select * from `evuser01` limit 0,20";

// database connection
$connection = mysql_connect("localhost", "wklapwyk", "cavalier");
mysql_select_db("evault");

// query results
$data = mysql_query($query, $connection);

// add grid to the page
echo activewidgets_grid($name, $data);
*/

function activewidgets_grid($name, &$data){

$row_count = @mysql_num_rows($data);
$column_count = @mysql_num_fields($data);


$columns = "var ".$name."_columns = [";
for ($i=0; $i < $column_count; $i++) {
$columns .= "\"".@mysql_field_name($data, $i)."\", ";
}
$columns = substr($columns,0,strlen($columns)-2) . "];\n";

$rows = "var ".$name."_data = [";
$myData = "[";
while ($result = @mysql_fetch_array($data)) {
$rows .= "[";
$myData .= "[";
for ($i=0; $i < $column_count; $i++) {
$rows .= "\"".activewidgets_html($result[$i])."\", ";
$myData .= "\"".activewidgets_html($result[$i])."\", ";
}
$rows = substr($rows,0,strlen($rows)-2) . "],";
$myData = substr($myData,0,strlen($myData)-2) . "],";
}
$rows = substr($rows,0,strlen($rows)-1) . "];\n";
$myData = substr($myData,0,strlen($myData)-1) . "];\n";

$doug = "Doug";
$html = "<script language=\"Javascript\">\n";
$html .= " <!--\n";
$html .= " " . $columns;
$html .= " " . $rows;
$html .= " try {\n";
$html .= " // provide cells and headers text\n";
$html .= " $name.setCellText($myData);\n";
$html .= " $name.setHeaderText($columns);\n\n";
$html .= " // set number of rows/columns\n";
$html .= " $name.setRowCount($row_count);\n";
$html .= " $name.setColumnCount($column_count);\n\n";
$html .= " // enable row selectors\n";
$html .= " $name.setSelectorVisible(true);\n";
$html .= " $name.setSelectorText(function(i){return this.getRowPosition(i)+1});\n\n";
$html .= " // set headers width/height\n";
$html .= " $name.setSelectorWidth(28);\n";
$html .= " $name.setHeaderHeight(20);\n\n";
$html .= " // set row selection\n";
$html .= " $name.setSelectionMode('single-row');\n\n";
$html .= " // set click action handler\n";
$html .= " $name.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};\n\n";
$html .= " // write grid html to the page\n";
$html .= " document.write($name);\n";
$html .= " }\n";
$html .= " catch (error){\n";
$html .= " document.write(error.description);\n";
$html .= " }\n";
$html .= " //-->\n";
$html .= " window.onload = function(){\n";
$html .= " $name.refresh();\n";
$html .= " }\n";
$html .= " </script>\n";

return $html;
}

function activewidgets_html($msg){

$msg = addslashes($msg);
$msg = str_replace("\n", "\\n", $msg);
$msg = str_replace("\r", "\\r", $msg);
$msg = htmlspecialchars($msg);

return $msg;
}

?>
Wayne K.
October 10,
try to use print_r($data) first inside the function activewidgets_grid.. if the data shows, then the parameter passing is fine.. after that, place the grid inside a frame. that would work. basically, most of us here place the grid inside an iframe.. just try it.. :)
anonymous me
October 10,
// ActiveWidgets PHP functions
$query = "
SELCT pmsCompName, pmsAcctNum, pmsCompCity from payeemast ORDER BY pmsCompName";

... that sure means SELECT ;)
Simon Milic
October 10,

This topic is archived.

See also:


Back to support forum