PHP: Sorting HTML table

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP: Sorting HTML table
# 1  
Old 02-04-2008
PHP: Sorting HTML table

Hi All,

I have an html table which looks like this:

<table align="center" border="1">
<CAPTION><EM>Heading for Table</EM></CAPTION>
<tr><td>88088283</TD> <TD>87613101</TD> <TD>91065136</TD> <TD>90939184</TD> <TD>357705704</TD> <TD>20080101</TD></TR>
<tr><td>67003875</TD> <TD>0</TD> <TD>68608549</TD> <TD>69344616</TD> <TD>204957040</TD> <TD>20080102</TD></TR>
<tr><td>70445888</TD> <TD>69669279</TD> <TD>72734855</TD> <TD>72698451</TD> <TD>285548473</TD> <TD>20080103</TD></TR>
<tr><td>75203597</TD> <TD>74166049</TD> <TD>77088902</TD> <TD>77553365</TD> <TD>304011913</TD> <TD>20080104</TD></TR>
<tr><td>75407465</TD> <TD>74000577</TD> <TD>77484901</TD> <TD>77722206</TD> <TD>304615149</TD> <TD>20080105</TD></TR>
<tr><td>70941100</TD> <TD>69062434</TD> <TD>72901670</TD> <TD>72736699</TD> <TD>285641903</TD> <TD>20080106</TD></TR>
<tr><td>74969415</TD> <TD>0</TD> <TD>76982435</TD> <TD>77293684</TD> <TD>229245534</TD> <TD>20080107</TD></TR>
<tr><td>73442971</TD> <TD>73491800</TD> <TD>74911504</TD> <TD>75764739</TD> <TD>297611014</TD> <TD>20080108</TD></TR>
<tr><td>72764725</TD> <TD>71652242</TD> <TD>75211152</TD> <TD>75074544</TD> <TD>294702663</TD> <TD>20080109</TD></TR>
<tr><td>73454942</TD> <TD>72505339</TD> <TD>75438966</TD> <TD>75913839</TD> <TD>297313086</TD> <TD>20080110</TD></TR>
<tr><td>79815952</TD> <TD>78689631</TD> <TD>81804681</TD> <TD>82456810</TD> <TD>322767074</TD> <TD>20080111</TD></TR>
<tr><td>79137022</TD> <TD>77709453</TD> <TD>81408526</TD> <TD>81605959</TD> <TD>319860960</TD> <TD>20080112</TD></TR>
<tr><td>69691604</TD> <TD>67968082</TD> <TD>72447070</TD> <TD>71706839</TD> <TD>281813595</TD> <TD>20080113</TD></TR>
<tr><td>73092537</TD> <TD>71841042</TD> <TD>76112287</TD> <TD>75582200</TD> <TD>296628066</TD> <TD>20080114</TD></TR>
<tr><td>72897146</TD> <TD>71747212</TD> <TD>76710776</TD> <TD>75522857</TD> <TD>296877991</TD> <TD>20080115</TD></TR>
<tr><td>72499894</TD> <TD>71322079</TD> <TD>75281052</TD> <TD>75006347</TD> <TD>294109372</TD> <TD>20080116</TD></TR>
<tr><td>0</TD> <TD>71642452</TD> <TD>75376018</TD> <TD>75347595</TD> <TD>222366065</TD> <TD>20080117</TD></TR>
<tr><td>79933449</TD> <TD>78704711</TD> <TD>76057329</TD> <TD>82645397</TD> <TD>317340886</TD> <TD>20080118</TD></TR>
<tr><td>79945569</TD> <TD>78533530</TD> <TD>79942644</TD> <TD>82131093</TD> <TD>320552836</TD> <TD>20080119</TD></TR>
<tr><td>70470436</TD> <TD>68800244</TD> <TD>70395060</TD> <TD>72214793</TD> <TD>281880533</TD> <TD>20080120</TD></TR>
<tr><td>73986480</TD> <TD>72839511</TD> <TD>74564917</TD> <TD>76104712</TD> <TD>297495620</TD> <TD>20080121</TD></TR>
<tr><td>72708987</TD> <TD>71762708</TD> <TD>71699084</TD> <TD>74911976</TD> <TD>291082755</TD> <TD>20080122</TD></TR>
<tr><td>73168024</TD> <TD>72090125</TD> <TD>73763260</TD> <TD>75412861</TD> <TD>294434270</TD> <TD>20080123</TD></TR>
<tr><td>73082636</TD> <TD>71643083</TD> <TD>75830466</TD> <TD>74909740</TD> <TD>295465925</TD> <TD>20080124</TD></TR>
<tr><td>81049767</TD> <TD>79787252</TD> <TD>82878510</TD> <TD>83402036</TD> <TD>327117565</TD> <TD>20080125</TD></TR>
<tr><td>81626016</TD> <TD>80092744</TD> <TD>82719853</TD> <TD>83928822</TD> <TD>328367435</TD> <TD>20080126</TD></TR>
<tr><td>72359198</TD> <TD>70381365</TD> <TD>74486040</TD> <TD>73801431</TD> <TD>291028034</TD> <TD>20080127</TD></TR>
<tr><td>74728557</TD> <TD>73141767</TD> <TD>76848788</TD> <TD>76462084</TD> <TD>301181196</TD> <TD>20080128</TD></TR>
<tr><td>73817203</TD> <TD>72436184</TD> <TD>75661172</TD> <TD>75733184</TD> <TD>297647743</TD> <TD>20080129</TD></TR>
<tr><td>72987373</TD> <TD>71633725</TD> <TD>74167105</TD> <TD>74872419</TD> <TD>293660622</TD> <TD>20080130</TD></TR>
<tr><td>76770354</TD> <TD>75333410</TD> <TD>77886260</TD> <TD>78873473</TD> <TD>308863497</TD> <TD>20080131</TD></TR>

What I need to do is sort the table by the date field - can anybody point me in the right direction?

I'm thinking I need to read the data lines (excluding the table and caption tags - which seems complicated in itself!) into an array and then sort (ksort?) the array?

Thanks in advance,

# 2  
Old 02-04-2008
As with all these things as soon as you ask you find the answer yourself Smilie

If anyone is interested the answer is here:

I've had to turn my html table input into a CSV first but that's easy.

Cheers, p.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Export HTML table

HI , I have a HTML tables as below. It has 2 tables ,I want to extract the second table . Please help me in doing it. <html> <body> <b><br>Running Date: </b>11-JAN-2019 03:07</br> <h2> Schema mapping and info </h2> <BR><TABLE width="100%" class="x1h" cellpadding="1"... (3 Replies)
Discussion started by: deepti01
3 Replies

2. Shell Programming and Scripting

Sorting a html file with an external sort order

I am working on a web-concordance of Old Avestan and my concordance has produced a HTML file The sort deployed by the HTML file is not something which we normally use. I have tried my best to force a sort within the concordance itself, but the sort order does not work. I am giving below the sort... (6 Replies)
Discussion started by: gimley
6 Replies

3. UNIX for Dummies Questions & Answers

Extract table from an HTML file

I want to extract a table from an HTML file. the table starts with <table class="tableinfo" and ends with next closing table tag </table> how can I do this with awk/sed... ---------- Post updated at 04:34 PM ---------- Previous update was at 04:28 PM ---------- also I want to... (4 Replies)
Discussion started by: koutroul
4 Replies

4. Web Development

Help on filtering the table in HTML

1. how to get the filter option on table so that user can enter the fields which ever they want to print only according to the need ? to print the full fledge table if there is no value in the rows of the table but it should print the whole rows and column in proper tabular form? (2 Replies)
Discussion started by: sidhi
2 Replies

5. Shell Programming and Scripting

Itinerate throught HTML table

HI all, <html> <body> <div> <table id="orderList"> <thead> <tr> <th>order number</th> <th>order type</th> <th>product type</th> <th>status</th> <th>status date</th> </tr> </thead> <tbody> <tr class="odd"> ... (10 Replies)
Discussion started by: valigula
10 Replies

6. Shell Programming and Scripting

Get HTML table

Hi all, I have a html that contains several tables in it. Need to extract the data from one of them named "orderList". Is it any easy way without using loops. Thanks (4 Replies)
Discussion started by: valigula
4 Replies

7. Shell Programming and Scripting

help with a bash script to create a html table

Hi guys as the title says i need a little help i have partisally written a bash script to create a table in html so if i use ./test 3,3 i get the following output for the third arguement in the script i wish to include content that will be replace the A characters in the... (2 Replies)
Discussion started by: dunryc
2 Replies

8. Shell Programming and Scripting

Format txt file as html table

I have a short time to solve a problem, so I need some help. I've searched the forum, but I couldn't find a solution to my problem. I made a script to filter some text and now I have a new requirement to make it available as html table. Problem is that I more than one files with different set... (2 Replies)
Discussion started by: tetreb
2 Replies

9. Shell Programming and Scripting

Export a HTML table to Xcel

Hello All, I have a perl script that prints a HMTL table. I want to convert this data into a report and this want to export this information into Excel. How can I do this? Regards, garric (3 Replies)
Discussion started by: garric
3 Replies

10. Shell Programming and Scripting

HTML table to CSV

Hi !! I have HTML Tables through which i want to generate graphs, but for creating graphs i need the file in CSV format so can anyone can please help me in how can i convert my HTML table file to CSV format. Thanks in Advance (2 Replies)
Discussion started by: i_priyank
2 Replies
Login or Register to Ask a Question