The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Export a HTML table to Xcel garric Shell Programming and Scripting 3 02-01-2008 01:46 AM
How do I extract text only from html file without HTML tag los111 UNIX for Dummies Questions & Answers 4 11-28-2007 12:40 AM
HTML table to CSV i_priyank Shell Programming and Scripting 2 11-15-2007 07:29 AM
Sorting a file - table?? noodlesoup Shell Programming and Scripting 3 09-10-2006 10:56 PM
table howeezy High Level Programming 1 09-23-2005 11:27 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: May 2004
Location: UK
Posts: 74
PHP: Sorting HTML table

Hi All,

I have an html table which looks like this:

Code:
<table align="center" border="1">
<CAPTION><EM>Heading for Table</EM></CAPTION>
<tr><td><b>1</b></TD><TD><b>2</b></TD><TD><b>3</b></TD><TD><b>4</b></TD><TD><b>TOTAL</b></TD><TD><b>DATE</b></td></tr>
<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>
</table>
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,

p.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: May 2004
Location: UK
Posts: 74
As with all these things as soon as you ask you find the answer yourself

If anyone is interested the answer is here: http://www.phpbuilder.com/snippet/do...nippet&id=1885

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

Cheers, p.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0