Stock Market Portfolio
Let's say we would like to design a PHP/MySQL dynamic web application for users to manage their personal stock portfolios. The stock data are kept in a table like the following:
name |
symbol |
last_trade |
volume |
change |
change_percent |
Lucent Technologies Inc. |
LU |
$3.20 |
166,922,900 |
+0.03 |
0.95 |
Nortel Networks Corporation |
NT |
$3.06 |
37,914,900 |
+0.13 |
4.44 |
Time Warner Inc. |
TWX |
$16.69 |
27,816,900 |
-0.11 |
0.65 |
Pfizer Inc. |
PFE |
$25.09 |
24,630,700 |
-0.08 |
0.32 |
Motorola Inc. |
MOT |
$23.77 |
22,934,600 |
+0.48 |
2.06 |
Ford Motor Company |
F |
$7.65 |
22,898,400 |
+0.08 |
1.06 |
Merck & Co Inc. |
MRK |
$34.84 |
21,049,200 |
-1.15 |
3.20 |
General Electric Company |
GE |
$34.51 |
20,222,500 |
+0.09 |
0.26 |
Boston Scientific Corporation |
BSX |
$21.93 |
19,487,400 |
+0.24 |
1.11 |
AT&T Inc. |
T |
$26.45 |
17,838,200 |
-0.30 |
1.12 |
EMC Corporation |
EMC |
$13.62 |
17,452,900 |
-0.18 |
1.30 |
iShares MSCI Japan Index Fund |
EWJ |
$14.78 |
16,649,500 |
+0.07 |
0.48 |
Exxon Mobil Corporation |
XOM |
$62.09 |
15,409,100 |
-0.07 |
0.11 |
Goodman Global, Inc. |
GGL |
$20.05 |
14,329,400 |
+2.05 |
11.39 |
Rite Aid Corporation |
RAD |
$4.07 |
14,100,300 |
+0.06 |
1.50 |
Micron Technology Inc. |
MU |
$15.58 |
13,618,200 |
+0.02 |
0.13 |
Advanced Micro Devices, Inc. |
AMD |
$34.70 |
13,344,300 |
-0.08 |
0.23 |
Texas Instruments Inc. |
TXN |
$33.63 |
13,332,700 |
+0.41 |
1.23 |
BellSouth Corporation |
BLS |
$34.30 |
12,475,300 |
-0.51 |
1.47 |
UnitedHealth Group Inc. |
UNH |
$54.51 |
12,067,200 |
-0.79 |
1.43 |
St. Jude Medical, Inc. |
STJ |
$37.06 |
11,930,500 |
+0.81 |
2.23 |
Citigroup Inc. |
C |
$47.85 |
11,834,500 |
-0.41 |
0.85 |
Sprint Nextel Corporation |
S |
$26.40 |
11,607,900 |
-0.04 |
0.15 |
ConocoPhillips |
COP |
$67.25 |
11,314,700 |
+0.69 |
1.04 |
General Motors Corporation |
GM |
$19.55 |
10,492,900 |
-0.36 |
1.81 |
3M Company |
MMM |
$81.38 |
10,471,100 |
+3.92 |
5.06 |
Valero Energy Corporation |
VLO |
$62.80 |
10,096,400 |
+0.30 |
0.48 |
Verizon Communications |
VZ |
$33.68 |
9,662,900 |
-0.35 |
1.03 |
Spectrum Brands, Inc. |
SPC |
$15.51 |
9,366,000 |
-5.99 |
27.86 |
Corning Inc. |
GLW |
$26.35 |
9,164,500 |
+0.09 |
0.34 |
Assuming our table name is "stock", we can write some PHP code which will build our tree dynamically, using the stock names as captions for the nodes, and associating the rest information in the table with each node using the data property. This will allow us to perform actions like sorting the tree based on the actual stock values or the stock value changes. The user will probably want to have her stocks organized in her own categories, but for this example we will organize them in only 3 broad categories, those who went up, those who remained the same and those who went down. We will also set the tool tip for each node to the values in the table.
In the example below, the code is displayed against different background colors to indicate the different languages used, HTML, Javascript and PHP.
This is how our example above looks like:

|