如何动态创建多个jquery数据表?(How to dynamically create multiple jquery datatables?)

编程入门 行业动态 更新时间:2024-10-23 04:55:00
如何动态创建多个jquery数据表?(How to dynamically create multiple jquery datatables?)

我无法找到创建动态创建多个jquery数据表的最佳方法。

我想将某个MySQL数据库中的所有表显示为网页上的数据表。 我目前有一个PHP脚本,提供有关我的javascript文件的一个表的信息。 但是,我必须在php脚本中指定我想要显示哪个表,这意味着我不能对数据库中的所有表使用相同的脚本。 此外,表名将在数据库内不断变化。

理想情况下,我希望能够做到这样的事情:

dbtables = [json output from php script with a list of all tables] for(var i = 0; i < dbtables.length; i++) { [CREATE HTML FOR JQUERY DATATABLE] [POPULATE DATATABLE FROM AJAX SOURCE USING PHP SCRIPT and pass in dbtables[i] as table name] }

但我不知道该怎么做(或者它甚至是最好的方式)。

我正在使用这个脚本: http : //www.datatables.net/development/server-side/php_mysql

另外,由于每个表都有不同的数据,我是否需要在[CREATE HTML FOR JQUERY DATABLE]中为每个表指定不同的文档ID,如果需要,我该如何进行呢?

I'm having trouble figuring out the best way to create dynamically create multiple jquery datatables.

I want to display all the tables inside a certain MySQL database as datatables on a webpage. I currently have a php script that serves information about one table to my javascript file. However, I have to specify inside the php script which table I want to display which means I can't use the same script for all the tables in the database. In addition, the table names will constantly be changing inside the database.

Ideally, I would like for me to be able to do something like this:

dbtables = [json output from php script with a list of all tables] for(var i = 0; i < dbtables.length; i++) { [CREATE HTML FOR JQUERY DATATABLE] [POPULATE DATATABLE FROM AJAX SOURCE USING PHP SCRIPT and pass in dbtables[i] as table name] }

But I'm not sure how to do that (or if it's even the best way).

I am using this script: http://www.datatables.net/development/server-side/php_mysql

In addition, since each table will have different data, do I need to specify a different document ID for each table in [CREATE HTML FOR JQUERY DATABLE] and how do I go about doing that if needed?

最满意答案

我实际上通过创建一个请求来找出我的问题,该请求给了我数据库中所有表的名称,然后使用for循环遍历所有这些表并获取信息。 我试图在一个请求中完成所有这一切,但这也很有效。

I actually figured out my problem by creating one request that gave me the names of all the tables in my database and then using a for loop to go through all those tables and get information. I was trying to do this all in one request, but this worked just as well.

更多推荐

本文发布于:2023-07-24 00:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1239273.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   数据表   动态   multiple   datatables

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!