Showing 1 to 1 of 1 entries when I use php and mysqli to display the table
Showing 1 to 1 of 1 entries when I use php and mysqli to display the table
Hi, My question is similar to the one asked by jemz recently. However since there was no solution given I am asking it again.
I am using the simplest mysqli and php code to fetch data from a Mysql database and display it in a table using Data Tables.
The table displays but at the bottom of it , it says Showing 1 to 1 of 1 entries. So while it displays all entries, it only recognizes the first table entry. As such pagination and sorting functions won't and do not work.
If I remove the php bit that fetches the data and echos it out as data to the table and replace that block with the data as shown in the example at DataTables, ( Like below), then the table works correct.
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$3,120</td>
</tr>
.
.
.
The moment I try and use php and mysqli to churn out the data in a while loop I get the error.
I tried making a test case in Data Tables Live but how & where do I connect to the mysql ? I can append my code here but I am not sure if that is permitted.
Kindly help me on this please
Thank you very much.
Replies
Hi Looking for some of the Gurus to have a look at this small issue and provide some clue as to what should I may do to get going with the tables.
Thanks all for any help or pointers.
Hi fellas,
Was hoping to get some response on this issue. Please help needed!
Thanks
Please link to a test page showing the issue as noted in the forum rules.
Allan
Hi Allan I would like to but I don't know have an active website. I don't know how to attach the code on DataTables,live or JSFiddle to a mysql table.
I can however paste the code that I was tryiig here if that's permitted. Its very short and sweet. Await your reply and thanks loads for the reply.
Sure. Best to post it into paste bin or jsfiddle etc.
Allan
Hi Allan,
Thanks. So I will paste the code here now. It will create the required data table on the first run and show the table as i am receiving it. If it needs to be run again then the block which creates the Table needs to be commented out since the table will be already created after the first run.
Thanks and please help me solve this. Will await your reply.
Hi Allan,
I have also created a new pastebin account. I have pasted the code there under the name dataTables Issue. Looking forward to a reply.
Thanks loads
Your created HTML is not valid. You are creating a new
tbody
for every row, and only closing one. Move thetbody
tag out of the loop.Allan
Damn ! What an oversight. Thanks Allan, That Solved it !
Thank you very Much.
Hi Can someone please tell me how to mark this thread as Answered. I can't find any option that would allow me to do so.
Thanks.
This thread wasn't opened as a question so it can't be marked as answered.
Good to hear it works for you though.
Allan
Thanks Allan