This code, get a query from db and fill the template docx with that data, the only thing that is filled is not the data from the database, I already did output of the data i tried to insert and it seems fine, i guess i'm missing something in replacing the text, but i cant find where. Can someone help me?
require_once APPPATH.'PHPWord.php';
        //$i=0;
        // Create a new PHPWord Object
        $PHPWord = new PHPWord();
        //get query
        $queryResult = $this->get($id);
        //load template
        $document = $PHPWord->loadTemplate($queryResult[0]['template_location']);
        $document->setValue('weekday', date('l'));
        $document->setValue('time', date('H:i'));
        $result = mysql_query($queryResult[0]['query_sql']) or die (mysql_error());
        $i=1;
        while($row = mysql_fetch_row($result))
        {
            for($aux=0; $aux < mysql_num_fields($result); $aux++)
            {
                if(!isset($row[$aux]))  
                    $value = NULL;  
                elseif ($row[$aux] != "")  
                    $value = strip_tags($row[$aux]);
                else  
                    $value = "";
                $document->setValue($i, $value);
                echo $i,"=",$value, " ";
                $i++;
            }
        }
        $document->save('report.docx');
    }
 
     
    