Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Reply
 
LinkBack Thread Tools Display Modes
Old 02-11-2011, 09:41 PM   #1 (permalink)
Apprentice
 
Join Date: Jul 2009
Posts: 62
Default making pivot style table in php


Hi

am new in php and am developing an interface for our team.
now here is some bottleneck i need to eliminate. Following is my code example

Code:
$results1=pg_query("select rpc.productkey, rpc.actiontype, rpc.rate from mytable1 rpc, mytable2 r where rpc.resellerid=r.resellerid and rpc.resellerid in (".$txtrid.") order by resellerid, productkey, actiontype");

print "<p><b>Reseller Pricing Details:</b><p>";   
print "<p><table border='1' cellpadding='1' cellspacing='1'><tr>";
print "<th>Product Key</th>";
print "<th>Action Type</th>";
print "<th>Pricing</th></tr>";

while($db_fields1=pg_fetch_assoc($results1))
{
print "<tr><td>".$db_fields1['productkey']."</td>";
print "<td>".$db_fields1['actiontype']."</td>";
print "<td>".$db_fields1['rate']."</td></tr>";
}
print "</table";
pg_close($pg_handle);
output i get is like this

Product Key | Action Type |
dombiz | addnewdomain |
dombiz | addtransferdomain |
dombiz | renewdomain |
dombiz | restoredomain |
domcno | addnewdomain |
domcno | addtransferdomain |
domcno | renewdomain |
domcno | restoredomain |
dominfo | addnewdomain |
dominfo | addtransferdomain |
dominfo | renewdomain |
dominfo | restoredomain |
domorg | addnewdomain |
domorg | addtransferdomain |
domorg | renewdomain |
domorg | restoredomain |
domus | addnewdomain |
dotco | addnewdomain |
dotco | addtransferdomain |
dotco | renewdomain |
dotin | addnewdomain |
dotin | addtransferdomain |
dotin | renewdomain |
dotin | restoredomain |
dotme | addnewdomain |
dotmobi | addnewdomain |
dotmobi | addtransferdomain |
dotmobi | renewdomain |
dotnet | addnewdomain |
dotnet | addtransferdomain |
dotnet | renewdomain |
dotnet | restoredomain |
thirdleveldotco | addnewdomain |
thirdleveldotco | addtransferdomain |
thirdleveldotco | renewdomain |
thirdleveldotin | addnewdomain |
thirdleveldotin | addtransferdomain |
thirdleveldotin | renewdomain |
thirdleveldotin | restoredomain |

now i want a pivot like output similar to like this

| addnewdomain | addtransferdomain | renewdomain | restoredomain
dombiz | 0.35 | 0.35 | 0.35 | 5
domcno | 0.35 | 0.35 | 0.35 | 5
dominfo | 0.35 | 0.35 | 0.35 | 5
domorg | 0.35 | 0.35 | 0.35 | 5
domus | 6.39 | | |
dotco | 23.5 | 23.5 | 23.5 |
dotin | 0.2 | 0.2 | 0.2 | 5
dotme | 20 | | |
dotmobi | 13.49 | 13.49 | 13.49 |
dotnet | 0.35 | 0.35 | 0.35 | 5
thirdleveldotco | 11.99 | 11.99 | 11.99 |
thirdleveldotin | 0.2 | 0.2 | 0.2 | 5

dunno how to do about it as i am new to php. kindly help me on this

Last edited by abhijeet2021; 02-11-2011 at 10:39 PM.
abhijeet2021 is offline   Reply With Quote
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Reply

Bookmarks

Thread Tools
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

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


 
Latest Threads
- by Charan
- by Sarath
- by clmlbx

Advertisement




All times are GMT +5.5. The time now is 12:36 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2