TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-12-2008, 12:27 AM   #1 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default 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:
$group explode(","mysql_group_column);
$name explode(","mysql_name_column);
$data explode(","mysql_data_column);

for (
$i 0$i count($group); ++$i)
{
  
$extraArray[] = array('group' => $group[$i], 'name' => $name[$i], 'data' => $data[$i]);

After the above, I have an array like
HTML Code:
Array
(
    [0] => Array
        (
            [group] => Metal Information
            [name] => Cut
            [data] => Clear
        )
    [1] => Array
        (
            [group] => Metal Information
            [name] => type
            [data] => Strong
        )
    [2] => Array
        (
            [group] => Stone Information
            [name] => Length
            [data] => 4\"
        )
    [3] => Array
        (
            [group] => Stone Information
            [name] => Color
            [data] => White
        )
    [4] => Array
        (
            [group] => Stone Information
            [name] => Width
            [data] => 3\"
        )
    [5] => Array
        (
            [group] => Stone Information
            [name] => Type
            [data] => Diamond
        )
)
I want to be able to output a table that looks something like
HTML Code:
 Stone Information
  Length 4"
  Color  white
  Type   Diamond
  
 Metal Information
  Cut    Clear
  Type   Strong
I think my problem is that the initial data shouldn't all be read into one array. But since the group item can be anything and any number of groups, I can't see how to programatically read this in and separate it right from the start. Can someone please provide some ideas on how I can accomplish this?
benton is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:27 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design