我无法找到创建动态创建多个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.
更多推荐
发布评论