FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » 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
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
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 [message #174216] Fri, 27 May 2011 10:45 Go to next message
styliek is currently offline  styliek
Messages: 3
Registered: May 2011
Karma: 0
Junior Member
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 ?
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 [message #174217 is a reply to message #174216] Fri, 27 May 2011 11:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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(at)attglobal(dot)net
==================
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 [message #174218 is a reply to message #174217] Fri, 27 May 2011 12:17 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
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
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 [message #174219 is a reply to message #174216] Fri, 27 May 2011 12:49 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
styliek <styliek(at)gmail(dot)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
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 [message #174220 is a reply to message #174219] Fri, 27 May 2011 13:13 Go to previous messageGo to next message
styliek is currently offline  styliek
Messages: 3
Registered: May 2011
Karma: 0
Junior Member
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','ta bBodyColPerc','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
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 [message #174221 is a reply to message #174220] Fri, 27 May 2011 13:45 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
styliek <styliek(at)gmail(dot)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
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 [message #174222 is a reply to message #174221] Fri, 27 May 2011 14:33 Go to previous messageGo to next message
styliek is currently offline  styliek
Messages: 3
Registered: May 2011
Karma: 0
Junior Member
> 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
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 [message #174223 is a reply to message #174220] Fri, 27 May 2011 15:07 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: addsworld
Next Topic: mysqli_stmt::store_result?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 21:23:40 GMT 2024

Total time taken to generate the page: 0.02164 seconds