:: Forum >> Version 1 >>

Does grid template support mysql?

I want to use the aw grid to display and edit data but i cant get it to work. Does aw template mysql
I have a deadline comin up and it wud be great if i could get this goin 2day

Here is my code:

<html>


<
head>

    <
title>PHP table</title>
      <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;} </style>



    <!-- 
ActiveWidgets stylesheet and scripts -->
    <
link href="..runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <
script src="../runtime/lib/grid.js"></script>

    <!-- 
ActiveWidgets PHP functions -->
       <
?php include("activewidgets.php"?>

    <!-- 
grid format -->
        <
style>
        .
active-templates-input {
            
overflowhidden;
            
width100%;
            
height100%;
            
padding0px 5px;
            
margin: -1px 0px;
            
border1px solid #666;
            
vertical-alignmiddle;
            
fontmenu;
            
line-height1.4em;
        }

        .
active-templates-input.gecko {
            
displayblock;
            
margin0px;
        }

   </
style>

     <!-- 
grid data -->
    <
script>

   if (!
window.MyMy=[];
if (!
My.TemplatesMy.Templates=[];

My.Templates.Input Active.Templates.Text.subclass();

My.Templates.Input.create = function()
{
    var 
obj this.prototype;

//    editor is not part of the template,
//    there is only one single instance of editor object.
    
var editor = new Active.HTML.INPUT;
    
editor.setClass("templates""input");
    
editor.setAttribute("type""text");
    
editor.setAttribute("value", function(){
        return 
template.getItemProperty("text");
    });

//    template variable provides temporary reference
//    to the parent template during edit mode.
    
var template;

    function 
switchToEditMode(){
        if (
template) {
            
switchToTextMode()
        }
        
template this;
        
template.element().style.padding 0;
        
template.element().innerHTML editor;
        
editor.element().focus();
    }

    
obj.setEvent("ondblclick"switchToEditMode);

    function 
switchToTextMode(){
        var 
value =    editor.element().value;
        
template.setItemProperty("text"value);
        
template.refresh();
        
template null;
    }

    
editor.setEvent("onblur"switchToTextMode);
};

My.Templates.Input.create();


var 
myData = new Array();


<
?
  $link 
mysql_connect("127.0.0.1""****""******");
     
//  echo "Connection made";
       
mysql_select_db("test");
       
register_shutdown_function($close);


$sql "Select `Hostname` , `Spec` , `Booked_By` , `Project` , `Subproject` ,`Proj_Mgr`, `Dept_Mgr`, `Purpose`, `Comments`, `TestSite_Type` from `tp`";
$result mysql_query($sql $link);



 while ( 
$row mysql_fetch_array($result))
{
echo 
'myData.push["'.$row['Hostname']
.
'","'.$row['Spec']
.
'","'.$row['Booked_By']
.
'","'.$row['Project']
.
'","'.$row['Subproject']
.
'","'.$row['Proj_Mgr']
.
'","'.$row['Dept_Mgr']
.
'","'.$row['Purpose']
.
'","'.$row['Comments']
.
'","'.$row['TestSite_Type'].'"'
.']';
}

?>




var 
myColumns = [ "Hostname""Spec""Booked_By""Project""Subproject" "Proj_Mgr" "Dept_Mgr" "Purpose" ,"Comms" "TestSite_Type" ];

</
script>

</
head>
<
body>
<
script>
// create ActiveWidgets Grid javascript object
    
var obj = new Active.Controls.Grid;

    
// set number of rows/columns
    
obj.setRowCount(20);
    
obj.setColumnCount(5);

    
// provide cells and headers text
    //    create editable text template
    
var templ = new My.Templates.Input;

    
//    assign new template to all columns
    
obj.setColumnTemplate(templ);

    
//    provide methods for getting and setting data
    
obj.getDataText = function(ij){return myData[i][j]};
    
obj.setDataText = function(valueij){myData[i][j] = value};

    
obj.setColumnText(function(i){return myColumns[i]});


    
//  disable arrow key nevigation
      
obj.setEvent("onkeydown"null);

      
//  make input box selectable
      
obj.getTemplate("top").setEvent("onselectstart"obj.getEvent("onselectstart"));
      
obj.setEvent("onselectstart"null);


    
// set click action handler
    //obj.setAction("click", function(src){window.status = src.getProperty("item/text")});
    // write grid html to the page
    
document.write(obj);

       </
script>
  </
body>
</
html
I keep getting a " 'My' is undefined " error .
I so frustrated now i feel like packin in aw alltogether and using something else.

Thanks for help



VERY-UPSET-DUDE
Wednesday, August 24, 2005
I think I catch it !!
end your <script> tags before php code <?
like:
var myColumns = [ "Hostname""Sp..............
</script>                        
<? 
  $link = mysql_connect("
127.0.0.1", "****", .................   
 
Wednesday, August 24, 2005
i had a few of my own errors in dat code sorry:

<html>


<
head>

    <
title>Hardware Requests :: PHP Example</title>
      <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;} </style>



    <!-- 
ActiveWidgets stylesheet and scripts -->
    <
link href="..runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <
script src="../runtime/lib/grid.js"></script>

    <!-- 
ActiveWidgets PHP functions -->
       <
?php include("activewidgets.php"?>

    <!-- 
grid format -->
        <
style>
        .
active-templates-input {
            
overflowhidden;
            
width100%;
            
height100%;
            
padding0px 5px;
            
margin: -1px 0px;
            
border1px solid #666;
            
vertical-alignmiddle;
            
fontmenu;
            
line-height1.4em;
        }

        .
active-templates-input.gecko {
            
displayblock;
            
margin0px;
        }

   </
style>




      <!-- 
grid data -->
    <
script>

   if (!
window.MyMy=[];
if (!
My.TemplatesMy.Templates=[];

My.Templates.Input Active.Templates.Text.subclass();

My.Templates.Input.create = function()
{
    var 
obj this.prototype;

//    editor is not part of the template,
//    there is only one single instance of editor object.
    
var editor = new Active.HTML.INPUT;
    
editor.setClass("templates""input");
    
editor.setAttribute("type""text");
    
editor.setAttribute("value", function(){
        return 
template.getItemProperty("text");
    });

//    template variable provides temporary reference
//    to the parent template during edit mode.
    
var template;

    function 
switchToEditMode(){
        if (
template) {
            
switchToTextMode()
        }
        
template this;
        
template.element().style.padding 0;
        
template.element().innerHTML editor;
        
editor.element().focus();
    }

    
obj.setEvent("ondblclick"switchToEditMode);

    function 
switchToTextMode(){
        var 
value =    editor.element().value;
        
template.setItemProperty("text"value);
        
template.refresh();
        
template null;
    }

    
editor.setEvent("onblur"switchToTextMode);
};

My.Templates.Input.create();


var 
myData = new Array();


<
?
   
// grid object name
    
$name "obj";

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

    
// database connection
    
$connection mysql_connect("local""$name""$pass");
    
mysql_select_db("test");

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

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

 
while ( $row mysql_fetch_array($data))



     {

echo 
'myData.push["'.$row['Hostname']
.
'","'.$row['Spec']
.
'","'.$row['Booked_By']
.
'","'.$row['Project']
.
'","'.$row['Subproject']
.
'","'.$row['Proj_Mgr']
.
'","'.$row['Dept_Mgr']
.
'","'.$row['Purpose']
.
'","'.$row['Comments']
.
'","'.$row['TestSite_Type'].'"'
.']';
}

?>




var 
myColumns = [ "Hostname""Spec""Booked_By""Project""Subproject" "Proj_Mgr" "Dept_Mgr" "Purpose" ,"Comms" "TestSite_Type" ];

</
script>

</
head>
<
body>
<
script>
// create ActiveWidgets Grid javascript object
    
var obj = new Active.Controls.Grid;

    
// set number of rows/columns
    
obj.setRowCount(20);
    
obj.setColumnCount(5);

    
// provide cells and headers text
    //    create editable text template
    
var templ = new My.Templates.Input;

    
//    assign new template to all columns
    
obj.setColumnTemplate(templ);

    
//    provide methods for getting and setting data
    
obj.getDataText = function(ij){return myData[i][j]};
    
obj.setDataText = function(valueij){myData[i][j] = value};

    
obj.setColumnText(function(i){return myColumns[i]});


    
//  disable arrow key nevigation
      
obj.setEvent("onkeydown"null);

      
//  make input box selectable
      
obj.getTemplate("top").setEvent("onselectstart"obj.getEvent("onselectstart"));
      
obj.setEvent("onselectstart"null);


    
// set click action handler
    
obj.setAction("click", function(src){window.status src.getProperty("item/text")});
    
// write grid html to the page
    
document.write(obj);

       </
script>
  </
body>
</
html
VERY-UPSET-DUDE
Wednesday, August 24, 2005
like this ?:


<html>


<
head>

    <
title>Hardware Requests :: PHP Example</title>
      <
stylebodyhtml {margin:0pxpadding0pxoverflowhidden;} </style>



    <!-- 
ActiveWidgets stylesheet and scripts -->
    <
link href="..runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <
script src="../runtime/lib/grid.js"></script>

    <!-- 
ActiveWidgets PHP functions -->
       <
?php include("activewidgets.php"?>

    <!-- 
grid format -->
        <
style>
        .
active-templates-input {
            
overflowhidden;
            
width100%;
            
height100%;
            
padding0px 5px;
            
margin: -1px 0px;
            
border1px solid #666;
            
vertical-alignmiddle;
            
fontmenu;
            
line-height1.4em;
        }

        .
active-templates-input.gecko {
            
displayblock;
            
margin0px;
        }

   </
style>




      <!-- 
grid data -->
    <
script>

   if (!
window.MyMy=[];
if (!
My.TemplatesMy.Templates=[];

My.Templates.Input Active.Templates.Text.subclass();

My.Templates.Input.create = function()
{
    var 
obj this.prototype;

//    editor is not part of the template,
//    there is only one single instance of editor object.
    
var editor = new Active.HTML.INPUT;
    
editor.setClass("templates""input");
    
editor.setAttribute("type""text");
    
editor.setAttribute("value", function(){
        return 
template.getItemProperty("text");
    });

//    template variable provides temporary reference
//    to the parent template during edit mode.
    
var template;

    function 
switchToEditMode(){
        if (
template) {
            
switchToTextMode()
        }
        
template this;
        
template.element().style.padding 0;
        
template.element().innerHTML editor;
        
editor.element().focus();
    }

    
obj.setEvent("ondblclick"switchToEditMode);

    function 
switchToTextMode(){
        var 
value =    editor.element().value;
        
template.setItemProperty("text"value);
        
template.refresh();
        
template null;
    }

    
editor.setEvent("onblur"switchToTextMode);
};

My.Templates.Input.create();


var 
myData = new Array();

var 
myColumns = [ "Hostname""Spec""Booked_By""Project""Subproject" "Proj_Mgr" "Dept_Mgr" "Purpose" ,"Comms" "TestSite_Type" ];
  </
script>

 <
?
   
// grid object name
    
$name "obj";

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

    
// database connection
    
$connection mysql_connect("127.0.0.1""root""123456");
    
mysql_select_db("test");

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

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

 
while ( $row mysql_fetch_array($data))



     {

echo 
'myData.push["'.$row['Hostname']
.
'","'.$row['Spec']
.
'","'.$row['Booked_By']
.
'","'.$row['Project']
.
'","'.$row['Subproject']
.
'","'.$row['Proj_Mgr']
.
'","'.$row['Dept_Mgr']
.
'","'.$row['Purpose']
.
'","'.$row['Comments']
.
'","'.$row['TestSite_Type'].'"'
.']';
}

?>

</
head>
<
body>
<
script>
// create ActiveWidgets Grid javascript object
    
var obj = new Active.Controls.Grid;

    
// set number of rows/columns
    
obj.setRowCount(20);
    
obj.setColumnCount(5);

    
// provide cells and headers text
    //    create editable text template
    
var templ = new My.Templates.Input;

    
//    assign new template to all columns
    
obj.setColumnTemplate(templ);

    
//    provide methods for getting and setting data
    
obj.getDataText = function(ij){return myData[i][j]};
    
obj.setDataText = function(valueij){myData[i][j] = value};

    
obj.setColumnText(function(i){return myColumns[i]});


    
//  disable arrow key nevigation
      
obj.setEvent("onkeydown"null);

      
//  make input box selectable
      
obj.getTemplate("top").setEvent("onselectstart"obj.getEvent("onselectstart"));
      
obj.setEvent("onselectstart"null);


    
// set click action handler
    
obj.setAction("click", function(src){window.status src.getProperty("item/text")});
    
// write grid html to the page
    
document.write(obj);

       </
script>
  </
body>
</
html
i tried dat and got the following error:

"myData[] is null or not an object".

and on de page itself was all this stuff:


myData.push["atrcus141","SFV440","EEIJCON","Maintenance","RC2.1 Sybase","EEIBHK","EEIPSN","Maintneance","2 * 3310 arrays. 1 * 73GB internal","System "]myData.push["atrcus51","SFV240","EEIKLS","R2.2 Maintenance","WRAN CM","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["netsim16","U10","EEIKLS","","","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["netsim205","SFV100","EEIKLS","","","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["atrcus21","SFV240","EEIKLS","R2.2 Maintenance","WRAN CM","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["attembak","SFV440","EEIEOCR","Backup/Restore","Backup/Restore","EEIEOCR","EEIBBH","Backup/Restore","","System "]myData.push["netsim254","SFV100","EEIKLS","","","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["atrcus19","SFV240","EEIKLS","R2.2","WRAN CM","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["atrcus107","SE250","EDBEDSR","R2","Maintenance","EDBEDSR","EEIJME","WRAN Ex / WRAN FWK / CSW Troubleshooting","","Feature "]myData.push["atrcus167","SFV890","EEIDDUA","P2.1","Maintenance","EEIDDUA","EEIPSN","R2 PLM","","System "]myData.push["atrnus73","SF280R","EEIIKY","R3","WRAN CM","EEIPLN","EEIJME","FET","","Feature "]myData.push["atrcus109","SE420","EEIDRYAN","R2.1","WRANCM","EEIPLN","EEIJME","FET","","Wilma "]myData.push["atrcus160","SFV890","EEIJCON","R3","NPT","EEIJCON","EEIMMUY","Large Upgrade","2 * 3510","System "]myData.push["netsim245","SFV100","EEIJTAR","","","EEIJCON","EEIMMUY","Wilma","","Wilma "]myData.push["atrcus102","SE250","EDBEDSR","R2","Maintenance","EDBEDSR","EEIJME","PCA Troubleshooting","","Feature "]myData.push["atrcus162","SFV890","EEIJCON","R3","NPT","EEIJCON","EEIMMUY","DDS","","System "]myData.push["atrcus82","SFV240","EDBEDSR","R2","Maintenance","EDBEDSR","EEIJME","PCA Troubleshooting","","Feature "]myData.push["atrcus106","SE250","EEIBBRY","R3","Radio","EEIBBRY","EEIJME","Design test","","Feature "]myData.push["atrcus163","SFV890","EEIJCON","R3","NPT","EEIJCON","EEIMMUY","Small Upgrade","","System "]myData.push["atrcus75","SFV240","EEIDOSY","R3","RNH","EEIBBRY","EEIJME","BIT","","Feature "] undefined


plaese please help
VERY-UPSET-DUDE
Wednesday, August 24, 2005
That's because css
Please revise your corrections !!
good luck

<link href="..runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>

INSTEAD OF

<link href="../runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
Wednesday, August 24, 2005
ok i replaced it now and the "'My' is undefined error is back.


<link href="..runtime/styles/xp/grid.css" rel="stylesheet" type="text/css" ></link>
    <
script src="../runtime/lib/grid.js"></script
any ideas?
VERY-UPSET-DUDE
Wednesday, August 24, 2005
Any one?
VERY-UPSET-DUDE
Wednesday, August 24, 2005
I would start by removing the MySQL and put in a dummy associative array. simplify the code, test, then add.

I played with your code for about the last 30 min and came up with undefined with JUST the Active Widget code (everything else commented out).
Jack9
Wednesday, August 24, 2005
thanks for your effort Jack9..

yes i tried it as u said there yesterday and it worked fine but when i want to add an sql db array i get dat stupid error that makes no sense..

" 'My' is undefined " error when clearly it is defined because it works with the dummy associative array.


I dono what to do anymore .is there another way of changing a mysql grid into an editable grid? if not will the new version support an mysql editable grid and when is it due out?

cheers.
VERY-UPSET-DUDE
Wednesday, August 24, 2005
MySQL doesnt interact with AW in any way. PHP reders the HTML (including the values from any Database) before AW even gets ahold of it. So we can be very very sure your problems are not with MySQL.

By examining the sourcecode of the page generated by the dummy array and the sourcecode generated by the mysql generated array, you will be able to see the practical differences that are causing the problem.
Jack9
Wednesday, August 24, 2005
ok im goin 2 try a few things i found out. il get back to ye.
VERY-UPSET-DUDE
Wednesday, August 24, 2005
hey,

my advice to you, you should have look at AW grid html source code .
You will know how the myData and myColumns being presented in javascript... its..

<script>
myData=[
["item0","item1","item2"],
["item0","item1","item2"],
["item0","item1","item2"]
];
myColumns=["col0","col1","col2"];
</script>
by using mysql ang php you should have an output like this...
if you use myData.push... you should have enclosed it with
like this
<script>
myData.Push(["item0","item1","item2"]);
</script>

glennlosentes
Wednesday, August 24, 2005
its the way you create the array from mysql.

remember, you're working with javascript here as well, so you CANNOT have something like this :

array[0][1] = "jou ma"array[0][2]="jou pa" like you did here :

myData.push["atrcus141","SFV440","EEIJCON","Maintenance","RC2.1 Sybase","EEIBHK","EEIPSN","Maintneance","2 * 3310 arrays. 1 * 73GB internal","System "]myData.push["atrcus51","SFV240","EEIKLS","R2.2 Maintenance","WRAN CM","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["netsim16","U10","EEIKLS","","","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push

you need a carriage return after each line or else it will give you an error.

In vb it is &vbcrlf

How many years programming experience do you have btw?
AcidRaZor
Thursday, August 25, 2005
wat ye on about.. i dont have dat in my code.. dats what was printed out on the screen... iv done 3 yrs in java in collage and im only doin php/javascript/html a week.
VERY-UPSET-DUDE
Thursday, August 25, 2005
java and javascript is very similar. i wanted to assess your experience because to me it seems you're not able to debug rather simple problems.

i'd suggest trying to go back to square one and play around with a working grid. then under examples there is a XML request example (called yahoo something) and look at how that functions.

from there it should be easy to understand
AcidRaZor
Thursday, August 25, 2005
but why did ye give me this

myData.push["atrcus141","SFV440","EEIJCON","Maintenance","RC2.1 Sybase","EEIBHK","EEIPSN","Maintneance","2 * 3310 arrays. 1 * 73GB internal","System "]myData.push["atrcus51","SFV240","EEIKLS","R2.2 Maintenance","WRAN CM","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push["netsim16","U10","EEIKLS","","","EEIKLS","EEIJME","Design/Test","","Feature "]myData.push


when its not even in my code.. r u tryin to explain to me that this is wrong:

while ( $row mysql_fetch_array($data)) 
 { 

echo 
'myData.push["'.$row['Hostname'
.
'","'.$row['Spec'
.
'","'.$row['Booked_By'
.
'","'.$row['Project'
.
'","'.$row['Subproject'
.
'","'.$row['Proj_Mgr'
.
'","'.$row['Dept_Mgr'
.
'","'.$row['Purpose'
.
'","'.$row['Comments'
.
'","'.$row['TestSite_Type'].'"' 
.']'
}  
VERY-UPSET-DUDE
Thursday, August 25, 2005
how is the xml example usefull to me when im using a mysql database?
VERY-UPSET-DUDE
Thursday, August 25, 2005
echo 'myData.push(["'.$row['Hostname']
.'","'.$row['Spec']
.'","'.$row['Booked_By']
.'","'.$row['Project']
.'","'.$row['Subproject']
.'","'.$row['Proj_Mgr']
.'","'.$row['Dept_Mgr']
.'","'.$row['Purpose']
.'","'.$row['Comments']
.'","'.$row['TestSite_Type'].'"'
.'])';

That is what people are saying you are outputting bad javascript
J
Thursday, August 25, 2005
sorry forgot the ;

echo 'myData.push(["'.$row['Hostname']
.'","'.$row['Spec']
.'","'.$row['Booked_By']
.'","'.$row['Project']
.'","'.$row['Subproject']
.'","'.$row['Proj_Mgr']
.'","'.$row['Dept_Mgr']
.'","'.$row['Purpose']
.'","'.$row['Comments']
.'","'.$row['TestSite_Type'].'"'
.']);';
J
Thursday, August 25, 2005
ok push doesnt work at all

but this works 4 1 line..

$row = mysql_fetch_array($data);

echo 'myData = [["'.$row['Hostname'].'","'.$row['Spec'].'","'.$row['Booked_By'].'","'.$row['Project'].'","'.$row['Subproject'].'","'.$row['Proj_Mgr'].'","'.$row['Dept_Mgr'].'","'.$row['Purpose'].'","'.$row['Comments'].'","'.ctype_xdigit($row['TestSite_Type']).'"]];'

now i need a while loop r sumthing to add all the query result to the array. like while($row = mysql_fetch_array($data))

does any1 have a quick solution to this cos i spent 4 days so far 2 get this much
VERY-UPSET-DUDE
Thursday, August 25, 2005
Yes, sorry I wasn't clear enough. The javascript output you did was bad.

Javascript is REALLY finicky about certain things. For instance :

myArray[0] = [1,2,3]
myArray[1] = [1,2,3]

would work, but

myArray[0] = [1,2,3]myArray[1] = [1,2,3]

would not.

The XML example is useful in the sense that you can execute a server side script (like ASP or PHP) and return a text array that will populate the grid. That way you don't have to physically code the array like you're trying to do, and just return a comma delimited (with a carriage feed return at the end of the row)

The grid will do the rest of the work.

hope im a bit more clear? english is not my first language
AcidRaZor
Thursday, August 25, 2005
i aggree its very hard 2 get it to work especially for alot of lines.

but if im updateing the table afterwords can i still use this method
VERY-UPSET-DUDE
Thursday, August 25, 2005
but for starters like and under pressure of project deadline
this will do...
$columns .= ($i>0 ? ",\"":"\"");    
        
$columns .= $tempdb->sql_fieldname($i,$tempres)."\"";
    }
    
    
$columns .= "\n];\n";

    
$rows "var myData = [\n"//START myData ARRAY CONTENT

    //sql_fetchrow is similar to while($row = mysql_fetch_array($data)) { ..do something }
    //but i used the for loop

    
for ($i=0$i <= $row_count-1$i++) {
        
$datarow $tempdb->sql_fetchrow($tempres);// similar to mysql_fetch_row
        
    // this will prevent your array to look like this myData=[,["val1","val2","val3"],["val1","val2","val3"]];
        
$rows .= ($i>0 ? ",[":"[");
        
        for (
$j=0$j <= $column_count-1$j++) {
            
$rows .= ($j>0 ? ",":" ");
            
$rows .= "\"".Nil(Modify_html($datarow[$j]),'-')."\" ";
        }
        
$rows .= "]\n";
    }
    
    
$rows .= "];\n";    //END myData ARRAY CONTENT
    

    // format javascript to ouput

    
$htmlstr "<"."script".">\n";
    
$htmlstr .= $columns;
    
$htmlstr .= "\n";
    
$htmlstr .= $rows;
    
$htmlstr .= "</"."script".">\n";

    
// output your javascript
    
    
echo $htmlstr;




/********************************
//    functions
/********************************/

function Modify_html($msg){

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

    return 
$msg;
}

 
*use your echo or print in such a way that it will output a good javascript syntax.
glennlosentes
Thursday, August 25, 2005
oh cheers glennlosentes. this looks very nice. a few questions if ur not 2 busy.

this is the mySql stuff :

$name "obj";

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

    
// database connection
    
$connection mysql_connect("local""$name""$pass");
    
mysql_select_db("test");

    
// query results
    
$data mysql_query($query$connection);  
so do i change dis line:

$columns .= $tempdb->sql_fieldname($i,$tempres)."\"";   to this


$columns .= $tempdb->sql_fieldname($i,$data)."\"";   sorry for asking stupid questions but im still learning.



VERY-UPSET-DUDE
Thursday, August 25, 2005
In my opinion, there were 2 things wrong with his original array creation. If he declared myData as an array and had a semi-colon after each push statement it should work. Change the code to look like this ans d give it a try.

echo 'var myData = new Array();';  // New line added
while ( $row mysql_fetch_array($data)) 

echo 
'myData.push["'.$row['Hostname'
.
'","'.$row['Spec'
.
'","'.$row['Booked_By'
.
'","'.$row['Project'
.
'","'.$row['Subproject'
.
'","'.$row['Proj_Mgr'
.
'","'.$row['Dept_Mgr'
.
'","'.$row['Purpose'
.
'","'.$row['Comments'
.
'","'.$row['TestSite_Type'].'"' 
.'];';        // this line was changed
}   
 
In the future, when someone offers you assistance, don't bad mouth them. When you were shown the output of YOUR CODE and it was explained why it didn't work, DON'T GET DEFENSIVE and state "wat ye on about.. i dont have dat in my code.. dats what was printed out on the screen... iv done 3 yrs in java in collage and im only doin php/javascript/html a week.". The person was correct and YOUR CODE DID PRODUCE THE RESULT on the screen. And for a supposed college educated person, you are extremely rude, ignorant, and can't handle basic debugging. And I really don't know why I even helped you out here except that perhaps if you have a solution you will be quiet and start respecting others and this thread will close. Many people have spent a lot of time with this issue and you don't seem at all grateful.

Good day...
VERY-UPSET at VERY-UPSET-DUDE
Thursday, August 25, 2005
NO...
i made a class for mysql database routines and used that class
<?php
/********************************************************************
 *                                 filename: mysql.php 
 ********************************************************************/




class sql_db
{

    var 
$db_connect_id;
    var 
$query_result;
    var 
$row = array();
    var 
$rowset = array();
    var 
$num_queries 0;

    
//
    // Constructor
    //
    
function sql_db($sqlserver$sqluser$sqlpassword$database$persistency true)
    {

        
$this->persistency $persistency;
        
$this->user $sqluser;
        
$this->password $sqlpassword;
        
$this->server $sqlserver;
        
$this->dbname $database;

        if(
$this->persistency)
        {
            
$this->db_connect_id = @mysql_pconnect($this->server$this->user$this->password);
        }
        else
        {
            
$this->db_connect_id = @mysql_connect($this->server$this->user$this->password);
        }
        if(
$this->db_connect_id)
        {
            if(
$database != "")
            {
                
$this->dbname $database;
                
$dbselect = @mysql_select_db($this->dbname);
                if(!
$dbselect)
                {
                    @
mysql_close($this->db_connect_id);
                    
$this->db_connect_id $dbselect;
                }
            }
            return 
$this->db_connect_id;
        }
        else
        {
            return 
false;
        }
    }

    
//
    // Other base methods
    //
    
function sql_close()
    {
        if(
$this->db_connect_id)
        {
            if(
$this->