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


Groups > comp.lang.php > #1871 > unrolled 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

Started bystyliek <styliek@gmail.com>
First post2011-05-27 03:45 -0700
Last post2011-05-27 11:07 -0400
Articles 8 — 4 participants

Back to article view | Back to comp.lang.php


Contents

  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

#1871 — 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

Fromstyliek <styliek@gmail.com>
Date2011-05-27 03:45 -0700
Subjectlooking 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
Message-ID<477d771b-cf31-46e0-9b1d-f2987bdfffd3@s2g2000yql.googlegroups.com>
Hi,

I have a table with 4 columns and say 10 rows
Column A only ever has 2 choices and column b has ten
I want to just have 2 rows that would look something like this
Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D

any suggestions ?

[toc] | [next] | [standalone]


#1872

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-27 07:05 -0400
Message-ID<iro0ia$8m8$1@dont-email.me>
In reply to#1871
On 5/27/2011 6:45 AM, styliek wrote:
> Hi,
>
> I have a table with 4 columns and say 10 rows
> Column A only ever has 2 choices and column b has ten
> I want to just have 2 rows that would look something like this
> Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
> Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
>
> any suggestions ?

Your question is not clear.  Are you looking for the PHP code to do 
this, or is it in a database and you're looking for the SQL statement?

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

[toc] | [prev] | [next] | [standalone]


#1873

Fromsheldonlg <sheldonlg@thevillages.net>
Date2011-05-27 08:17 -0400
Message-ID<iro4o6$17u$1@dont-email.me>
In reply to#1872
On 5/27/2011 7:05 AM, Jerry Stuckle wrote:
> On 5/27/2011 6:45 AM, styliek wrote:
>> Hi,
>>
>> I have a table with 4 columns and say 10 rows
>> Column A only ever has 2 choices and column b has ten
>> I want to just have 2 rows that would look something like this
>> Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
>> Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
>>
>> any suggestions ?
>
> Your question is not clear. Are you looking for the PHP code to do this,
> or is it in a database and you're looking for the SQL statement?
>

Not clear?  It was totally unintelligible.

-- 
Shelly

[toc] | [prev] | [next] | [standalone]


#1874

Fromcrankypuss <no@email.thanks>
Date2011-05-27 06:49 -0600
Message-ID<pb7vt61madc8btf52r3egpgqn7dhs2l1d9@4ax.com>
In reply to#1871
styliek <styliek@gmail.com> wrote:

>Hi,
>
>I have a table with 4 columns and say 10 rows
>Column A only ever has 2 choices and column b has ten
>I want to just have 2 rows that would look something like this
>Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
>Col A Col B Col C Col D Col B Col C Col D Col B Col C Col D
>
>any suggestions ?

Write some code to take what you have and store it in an array, then
write some more code to convert the array to whatever format you want.

If you can't do it from that explanation, post more words.

-- 
no aluminum siding offers today

[toc] | [prev] | [next] | [standalone]


#1875

Fromstyliek <styliek@gmail.com>
Date2011-05-27 06:13 -0700
Message-ID<5c94c216-5319-428a-a29b-ee25427153a1@x10g2000yqj.googlegroups.com>
In reply to#1874
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)... ??

.php

if (in_array($MetricTypeID,
array(1046,1051,1052,1054,1063,1074,1075,1103,1104))) {
                        array_push($DataTables['Sec'], sprintf("\t\t['/
metrics/PerformanceDetails.php?DeviceID=%s;MetricID=%s', '%s', '%s',
'%s', '%s']",
                                $DeviceID,
                                $MetricID,
                                $Instance,
                                $MetricType,
                                sprintf("%3.3f",
$Metrics[$MetricTypeID][$MetricID]['Average']),
                                sprintf("%3.3f",
$Metrics[$MetricTypeID][$MetricID]['Peak'])
                        ));


.html

var TABLE_LAYOUT_SEC = [
        {
                'name' : 'DataSetID',
                'type' : NUM,
                'hide' : true
        },
        {
                'name' : 'Instance',
                'type' : STR
        },
        {
                'name' : 'Metric Type',
                'type' : STR
        },
        {
                'name' : 'Avg Value',
                'type' : NUM
        },
        {
                'name' : 'Peak Value',
                'type' : NUM
        }
];

var TABLE_LOOK_SEC = {
        'onclick' : function (ThisRow, ThisRowValues, AllMarkedKeys) {
                var URL = ThisRowValues[0];
                location.href = URL;
        },
        // Indicates if multiple row selection mode for a table is on
        'multy_mark' : false,
        // 0 - caption,
        // 1 - header rows to be skipped at the top when applying
effects,
        // 2 - body,
        // 3 - footer rows to be skipped at the bottom when applying
effects,
        // 4 - paging,
        // 5 - filters
        'structure' : [0, 2],
        'params' : [3, 0], // [cellpadding,cellspacing]
        'colors' : {
                'even'    : 'white',
                'odd'     : '#DBEAF5',
                'hovered' : '#FFCCAA',
                'marked'  : '#FFCC66'
        },
        'freeze' : [0, 0], // how many rows to skip [at_the_top,
at_the_bottom] when applying effects
        'paging' : {
                'by' : 0, // page size (0 - no paging)
                'tt' : '&nbsp;Page %ind of %pgs&nbsp;'
        },
        'sorting' : {
                // HTML for ascending sorted state icon
                'as' : '<img src="../../images/
TableSortAscendingBlue.gif" border="0" height="4" width="8" alt="sort
descending">',
                // HTML for descending sorted state icon
                'ds' : '<img src="../../images/
TableSortDescendingBlue.gif" border="0" height="4" width="8" alt="sort
ascending">',
                // HTML for unsorted state icon
                'no' : '<img src="../../images/TableSortNoneBlue.gif"
border="0" height="9" width="8" alt="sort ascending">',
                'cl' : null,
                // Order of sorted: true - ascending sorted, false
descending sorted
                'or' : false
        },
        'filter' :{
                'type':0
        },
        'css' : {
                'main'     : 'tabTable',
                'body'     :
['','tabBodyColDesc','tabBodyColDesc','tabBodyColText','tabBodyColText','tabBodyColPerc','tabBodyColPerc'],
                'captCell' : 'tabCaptionCell',
                'captText' : 'tabCaptionLink',
                'head'     : 'tabHeadCell',
                'foot'     : 'tabFootCell',
                'pagnCell' : 'tabPaging',
                'pagnText' : 'tabPagingText',
                'pagnPict' : 'tabPagingArrowCell',
                'filtCell' : 'tabFilter',
                'filtPatt' : 'tabFilterPattern',
                'filtSelc' : 'tabFilterSelect'
        }
};








{if (array_key_exists('SEC', $TableItems))}
 
<table border="0" cellspacing="0" cellpadding="0" class="FieldSet">
 
<tr>
 
<td height="4" width="7" class="TopLeft"><img src="../../images/
1Pixel.gif" height="4" width="7" /></td>
 
<td height="4" width="100%" class="TopCenter"></td>
 
<td height="4" width="7" class="TopRight"><img src="../../images/
1Pixel.gif" height="4" width="7" /></td>
 
</tr>
 
<tr>
 
<td width="7" class="MiddleLeft"></td>
 
<td class="MiddleCenter" height="100%" style="vertical-align: top">
 
<span class="FieldSetContentTitle">SLA Time Metrics Collected</span>
 
<br>
 
<img src="../../images/FieldSetHorizontalSeparatorLeft.png"
alt="Horizontal Separator">
 
<p>
 
<table align=left bgcolor="#336699" cellpadding="0" cellspacing="0"
valign="top" align="center" style="background: #336699 url(../../
images/1PixelGray.png) top right no-repeat">
 
<tr>
 
<td style="background: url(../../images/1PixelGray.png) top left no-
repeat">
 
<table width=100% cellpadding="1" cellspacing="0" valign="top"
align="center">
 
<tr>
 
<td>
 
<script type="text/javascript">
 
new TTable(TABLE_LAYOUT_SEC, TABLE_CONTENT_SEC, TABLE_LOOK_SEC);
 
</script>
 
</td>
 
</tr>
 
</table>
 
</td>
 
</tr>
 
</table>
 
</td>
 
<td width="7" class="MiddleRight"></td>
 
</tr>
 
<tr>
 
<td height="4" width="7" class="BottomLeft"></td>
 
<td height="4" class="BottomCenter"></td>
 
<td height="4" width="7" class="BottomRight"></td>
 
</tr>
 
</table>

Thanks for any advice/opinions

[toc] | [prev] | [next] | [standalone]


#1876

Fromcrankypuss <no@email.thanks>
Date2011-05-27 07:45 -0600
Message-ID<8navt6pfk589pfc79edc3mn12haifn2gqs@4ax.com>
In reply to#1875
styliek <styliek@gmail.com> 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)... ??

Your problem is that you think an html file is generating code and you
don't know how to write the PHP to do the job.  Pay someone money.

-- 
no aluminum siding offers today

[toc] | [prev] | [next] | [standalone]


#1877

Fromstyliek <styliek@gmail.com>
Date2011-05-27 07:33 -0700
Message-ID<95fa154d-c2df-42d3-8f46-b51c9ec0665e@x3g2000yqj.googlegroups.com>
In reply to#1876
> Your problem is that you think an html file is generating code and you
> don't know how to write the PHP to do the job.  Pay someone money.
>
> --
> no aluminum siding offers today

I never said html is generating code, I put the structure of the html
there because I thought it might be helpful, I could include all the
php code that is pulling data from the db and manipulating it, but I
thought the php code that writes to the html might be more relevant.
I came here looking for pointers and opinions so I can work on the
problem myself

[toc] | [prev] | [next] | [standalone]


#1878

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-05-27 11:07 -0400
Message-ID<iroen7$6ip$1@dont-email.me>
In reply to#1875
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
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web