Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #1878

Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end
Date 2011-05-27 11:07 -0400
Organization A noiseless patient Spider
Message-ID <iroen7$6ip$1@dont-email.me> (permalink)
References <477d771b-cf31-46e0-9b1d-f2987bdfffd3@s2g2000yql.googlegroups.com> <pb7vt61madc8btf52r3egpgqn7dhs2l1d9@4ax.com> <5c94c216-5319-428a-a29b-ee25427153a1@x10g2000yqj.googlegroups.com>

Show all headers | View raw


On 5/27/2011 9:13 AM, styliek wrote:
> Hi,
>
> At the moment the .php is pulling data from the database, running a
> few sql's making sure its the data I want and then performs the below
> code to pass data to a html file which then proceeds to create the
> table. I have omitted some code If I omitted too much please let me
> know.
>
> My problem is that while the html table populates correctly with
> mulitple rows where Col A is only ever 2 things, I would rather have
> Col A containing unique data(table just has 2 rows) and have multiple
> columns instead corresponding to it (Col A row 1 Col A row 2)... ??
>

<code snipped>

There are several ways to do this.  For instance, you can build an array 
with two elements, one for each of the two values you want in the first 
column.  Each of these elements contains an array the other values 
values you want on that row, i.e.

Array {
   [Col_A_value_1]=>
     Array {
       Array {[0]=>Col_B_value_1, [1]=>Col_C_Value_1, [2]=>Col_D_Value_1}
       Array {[0]=>Col_B_value_2, [1]=>Col_C_Value_2, [2]=>Col_D_Value_2}
    }
   Col_A_value_2
     Array {
       Array {[0]=>Col_B_value_3, [1]=>Col_C_Value_3, [2]=>Col_D_Value_3}
       Array {[0]=>Col_B_value_4, [1]=>Col_C_Value_4, [2]=>Col_D_Value_4}
    }
etc.

Depending on your needs, you might also be able to put all the values 
for columns B, C, etc. in one array, i.e.

Array {[0]=>Col_B_value_1, [1]=>Col_C_Value_1, 
[2]=>Col_D_Value_1,[3]=>Col_B_value_2, [4]=>Col_C_Value_2, 
[5]=>Col_D_Value_2}

But a better way would be to let the database do the work for you, 
returning the data in the way which suits your needs.  Check a newsgroup 
for your database to see if this is possible.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end styliek <styliek@gmail.com> - 2011-05-27 03:45 -0700
  Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-27 07:05 -0400
    Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end sheldonlg <sheldonlg@thevillages.net> - 2011-05-27 08:17 -0400
  Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end crankypuss <no@email.thanks> - 2011-05-27 06:49 -0600
    Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end styliek <styliek@gmail.com> - 2011-05-27 06:13 -0700
      Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end crankypuss <no@email.thanks> - 2011-05-27 07:45 -0600
        Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end styliek <styliek@gmail.com> - 2011-05-27 07:33 -0700
      Re: looking for ideas on how turn a php created html table with 10 rows into a 2 row table with extra columns appended to the end Jerry Stuckle <jstucklex@attglobal.net> - 2011-05-27 11:07 -0400

csiph-web