0
Good morning Everyone, I created this page to automate a process in the company: http://pastebin.com/WdkdfWnN
However it only displayed the cute tables only when there is data returned in the query, in case there is not checked in google Chrome console returns error "Uncaught Typeerror: Cannot read Property 'length' of Undefined" and I diagnosed that the problem is because there is no data returned in the query. The code is not very correct anymore it works only when there is data. How to test whether data exists or not, because I add the IF condition plus the way it doesn’t work, always returns TRUE.
Without the code there is no help, this error seems javascript ...
– rray
The code is in Pastebin, http://pastebin.com/WdkdfWnN
– Victor Sued
Try replacing instead of
UNION
, placeUNION ALL
, and equals the field names, in the table that does not use data, putNULL as nomeCampo
or0 as NumeCampo
, or instead ofUNION ALL
, only one conditionIF(NomeCampo == NULL, 0,NomeCampo) as valor
. You can also create an output condition if you haven’t given.– Ivan Ferrer
You can run any other query like:
select 'Nenhum dado' as campo1, 'Nenhum dado' as campo2, 'Nenhum dado' as campo3
;– Ivan Ferrer
Take a look at this question http://meta.pt.stackoverflow.com/questions/4255/%C3%89-a-good-id%C3%A9ia-colocar-o-c%C3%B3digo-no-Pastebin-ao-Inv%C3%A9s-de-colocar-o-c%C3%B3digo-na-per
– Wallace Maxters
It seems to me to be a mistake to use the datatable component. You can do a check in php for if there are no rows returned in the query, add one (it needs to have td inside all tr), with a text like: No results found".
– Joao Paulo