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
Return to the default flat view Create a new topic Submit Reply
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:
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
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: addsworld
Next Topic: mysqli_stmt::store_result?
Goto Forum:
  

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

Current Time: Mon Nov 25 03:41:19 GMT 2024

Total time taken to generate the page: 0.04335 seconds