How to display table even without having result?

Asked

Viewed 61 times

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 ...

  • The code is in Pastebin, http://pastebin.com/WdkdfWnN

  • Try replacing instead of UNION, place UNION ALL, and equals the field names, in the table that does not use data, put NULL as nomeCampo or 0 as NumeCampo, or instead of UNION ALL, only one condition IF(NomeCampo == NULL, 0,NomeCampo) as valor. You can also create an output condition if you haven’t given.

  • You can run any other query like: select 'Nenhum dado' as campo1, 'Nenhum dado' as campo2, 'Nenhum dado' as campo3;

  • 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

  • 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".

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.