![]() |
Creating a table from loaded data
In this scenario, there are three fields in a database, group, name and data, that consists of comma spearated lists. I am trying to read those in, sort them and make a three column table from the data. So I have something like this after reading in the data:
PHP Code:
HTML Code:
ArrayHTML Code:
Stone Information |
When the information comes out of the database it is already in an array... Why make it harder to process?
Just put the group, name, and data all in a different array, and then do something like, PHP Code:
|
Maybe I'm missing the point, or didn't make mine, but that won't give any contol over the table I need to create. The user can input the items in the database in any order - group1, group3, group2 and so on. I need to be able to display all of the common groups under one heading. If I just read them in and display them, it will just display whatever it reads in (any order).
|
You problem here is the complete lack of refrence from the DB and like i read it, you should change the way it's being written into the DB.
If there is more than one information on "Metal Information" or "Stone Information" there is no way to sort out what belong to where. EX: HTML Code:
Array[group] => Metal Information | [name] => Cut | [data] => Clear would go with: [group] => Metal Information | [name] => type | [data] => Strong or [group] => Metal Information | [name] => type | [data] => Weak Try posting how you write the data to the DB and the form being used by the user. Also post how your table looks... |
OK. I'll try to explain it better. The database table has, among other items, the following columns
HTML Code:
table stone {HTML Code:
Group Text Data //title of table columnsHTML Code:
group = "g1","g2" HTML Code:
table stone {HTML Code:
g1 |
First off, sorry for the long answering time.
If you have not found a solution(requires PHP5) yet i would suggest to change a couple of things so that it would be easier to sort through the DB. First if you do not have it yet you will need a id field with NOT NULL, INT, AUTO_INCREMENT in your stone table. Second of change the group TEXT null to group_id INT NOT NULL Third make a new table called group. HTML Code:
CREATE TABLE `group` (Now use this to read you table data: PHP Code:
You have all the information you need in $data->Data, $data->iCount and $data->jCount. $data->Data[number][number]['text']/['data'] - Is containing the sorted data in an array. $data->iCount - Is containing the amount of groups in the array. $data->jCount[number] - Is countaining the amount of data in the second array of $data->Data From here you can extract the data from the array and put into tables. EX: PHP Code:
|
| All times are GMT. The time now is 08:55 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0