:: Forum >>

Weird Scenario - PHP/MSAccess

So, I've got perhaps not the most normal scenario in the world. I'm using PHP interface and Microsoft Access as my Database.
Luckily PHP has ODBC compatibility with MSAccess, so that's not a problem, but I just wanted to preface with that.

Basically, I'm looking to draw data from a multi-join query, and stick it into the Grid.

It is not working.

Here's my code:
[CODE]

<SCRIPT>
var myData = new Array;
<?
$num_rows = 0;
$query = odbc_exec($odbc, "SELECT ...");
while($row = odbc_fetch_array($query))
{ ?>
myData.push('["<?=$row['field1']?>", "<?=$row['field2']?>", "<?=$row['field3']?>"]');
$num_rows++;
<? }
?>
var obj = new Active.Controls.Grid;
obj.setProperty("column/count", 3);
obj.setProperty("row/count", <?=$num_rows?>);
obj.setProperty("data/text", function(i,j){return myData[i][j]});
document.write(obj);
</SCRIPT>

[/CODE]
On the output, I get a grid with the proper number of rows and columns, but all the fields are 'undefined'.
What am I doing wrong? I have a feeling it has something to do with my multidimensional array 'myData', because when I just have the line say: return myData[i]
it returns the proper data, but it doesn't split the array into each cell (if that made any sense...).
Any help would be truly appreciated
Tim Claason
Thursday, May 20, 2004
Aren't u missing a coma on the end of this line? (after the ])

myData.push('["<?=$row['field1']?>", "<?=$row['field2']?>", "<?=$row['field3']?>"],');
Rafael Fong
Thursday, May 20, 2004
I think the push automatically adds the comma
Thursday, May 20, 2004
I have figured it out. For those interested in the solution:

[CODE]
var myData = new Array;
<?
$num_rows = 0;
$query = odbc_exec($odbc, "SELECT ...");
while($row = odbc_fetch_array($query))
{
$field1 = $row['field1'];
$field2 = $row['field2'];
$field3 = $row['field3']; ?>
myData.push(["<?=$field1?>", "<?=$field2?>", "<?=$field3?>"]);
<?
}
?>
[/CODE]
I think part of the problem was where the [] were. Along with that, the '' in the $row[] variables were also creating a problem.
Tim Claason
Thursday, May 20, 2004
I'm glad you fixed it ;-) I was initially very much confused by the mix of client-side and server-side scripts in your code but it looks like a good idea for me now. There is also PHP example in the ActiveWidgets package but this one is for MySQL.
Alex (ActiveWidgets)
Thursday, May 20, 2004
Is there any chance of creating a ODBC version for PHP
HENRY
Monday, April 10, 2006

This topic is archived.


Back to support forum

Forum search