:: Forum >>

why doesn't this simple example work?

<html>
<head>
<!-- include AW stylesheet and script -->
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
</head>
<body>
<script>

// insert javascript arrays produced by PHP functions
var myHeaders = ["id","workorderid","description","cost","chargetype","duration"];
var myCells = [
    ["55","40","time","125","hourly","2"],
    ["56","30","helpme","20","hourly","2"],
    ["57","50","small order","125","hourly","2"]
];

// create grid control
var obj = new AW.UI.Grid;

// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);

// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);

// write grid to the page
document.write(obj);

</script>
</body>
</html>


I am totally baffled...

Why doesn't this work? I have been able to get other examples working, but this one has me at the end of my wits.
comptech
Monday, June 18, 2007
I gave-up and just modified another example to do what I want, however I just realised that it is always skipping the first row of my data

<?php
require_once("MDB2.php");


$dsn = 'mysql://user:password@localhost/table';
$db =& MDB2::Connect( $dsn, array() );
if (PEAR::isError($db)) { die($db->getMessage()); }

$qry = "SELECT * FROM workorders";

$dataset = $db->query($qry);



// print MySQL query results as 2D javascript array
function aw_cells($dataset){

while ($record = $dataset->fetchRow(MDB2_FETCHMODE_BOTH)) {
foreach ($record as $value) {
echo $value;
}
}
}


can anyone tell me why it is skipping the first row of data from the table? I've simplified it as much as I can think.
comptech
Monday, June 18, 2007
i was calling fetch row once before in my set headers function. Just incase someone else has that problem.
comptech
Sunday, June 24, 2007

This topic is archived.


Back to support forum

Forum search