PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm extracting data from a MySQL db, and populating the info into a MS Excel spreadsheet.
Everything is working just fine, with the exception of trying to put the rows returned from the db into an Array (there are more than 5 rows returned...just simplified here) and then spinning through that array and populating different cells with that variabls in the array. Can I store $varibles in an Array() as opposed to 'strings' ?
//Now spin through each in the array
for ($wCnt=1;$wCnt<=14;$wCnt++) {
$cell = $sheets->Cells($xRow,$yRow); //Select the cell
$cell->activate; //Activate the cell
$cell->value = $wArray[$wCnt]; //print value to cell
unset($cell);
//unset the cell var to create anew.
if ($yRow == 18) {
$yRow++;
} else {
$yRow --;
$xRow ++;
}
}
the code above works excellent. but the original code posted doesnt. I think because the $typeData array has $vars in it...whereas the $wArray array has strings of data from a query result.
How would I stored the variables into strings into the array?
referencing the variable directly works...but if i put all the variables in an array...there are over 20 different variables, then try to reference them in the for loop...it hangs the program.
I could do the above over 20 plus times...I just wanted to clean it up a bit with far less code by using the array and for loop.
$cell = $sheets->Cells(5,2) ; //$cell is assinged to the cell at (5,2)
$cell->activate; //(5,2) cell is activated.
$cell->value = $var1; //(5,2) cell is written with value from $var1
unset($cell); //clear cell object