-2
I have a problem calling the variable name to the Excel file name. I have to put Variavel’s name on the file. The variable name comes from Select * ...
//--- Fazendo o preenchimento inicial --------------------------
$row=mysql_fetch_array($sql);
//- Definimos o nome do arquivo que será exportado -------------
$arquivo = 'Empresa Não Autorizada '.$row[1]'.xls';
Give me this error: Parse error: syntax error, Unexpected ''. xls''
Hello. Where does the name variable come from? Where is it defined?
– Omni
The syntax of your code, besides being wrong, shows no relation to your doubt.
– gmsantos
I want it to be used when it is called by the query below
– ChrisAdler
@user3253195 I advise you to edit the question, correct the syntax and explain your question better. The way I read it looks like you’re trying to create the variable
$arquivo
and cannot.– Omni
I have a problem placing the file name with the variable $NAME
– ChrisAdler
@user3253195 as it has structured code,
$Nome
can never come fromSELECT *
. You will need to make a declaration of$arquivo
after$row=mysql_fetch_array($sql);
. And will remain$arquivo = ' Não Autorizada '.$row.'.xls';
. (If I understand you right).– Omni
@user3253195 missing one point after the
$row[1]
: $file = 'Unauthorized ' . $Row[1] . '. xls';– gmsantos
only one question. Can I have Select with *? or have to set one by one all fields?
– ChrisAdler
@user3253195 if you are sure that the BD schema will not change and that the field you want is always at position 1 there is no problem. However consider that you are selecting all columns (can be two or can be 20) when in fact you will only use one.
– Omni
But having several tables does not generate problem?
– ChrisAdler
Notice: Undefined offset: 1 in give me this error
– ChrisAdler
@user3253195 When you do the
Select * from Tabela
is only selecting the one table, not several. The*
means it will select all columns in the table. For Undefined offset the query can only have one field (PHP arrays start their indices at zero, so if there is only one column in$row
would have to be$row[0]
.– Omni
This question seems to be off-topic because it is about a typographical error whose solution benefits no future visitor.
– brasofilo
And it’s not the same thing you’ve asked in http://answall.com/questions/17371/exportar-dados-excel-php-workbench-variable?
– bfavaretto