You are here: Re: seeking suggestion for posting spreadsheet data on web « HTML « IT news, forums, messages
Re: seeking suggestion for posting spreadsheet data on web

Posted by Ross on 08/22/05 18:37

"william" <w.shakespeare1564@ntlworld.com> wrote in message
news:39iv2tv2jz8h.1dhbcedlvgxop$.dlg@40tude.net...
> On Mon, 22 Aug 2005 11:20:01 +0800, Ross wrote:
>
>> dear all, i have the following table of data to post on web,
>>
>> name size length 0min 3min 10min chart
>> A 3 5 1 10 3 figA.gif
>> B 5 2 2 4 3 figB.gif
>> C 4 3 3 9 6 figC.gif
>> ...
>>
>> I am seeking your advice on the programming language for such an action.
>> i
>> prefer a web table capable of sorting by size, length and so on,
>> therefore
>> built-in function for sorting is appreciated
>
> php is your best bet
>
> <?php
> /* this is where the array values are assigned*/
> $table_data= array(array ( 'a', 3, 5, 1, 10, 3, 'figA.gif' ),
> (array ( 'b', 5, 2, 2, 4, 3, 'figB.gif' )),
> (array ( 'c', 4, 3, 3, 9, 6, 'figC.gif'
> ))
> );
> /* This is where you describe the funtion "compare". The number in the
> square bracket corresponds with the column in the array, remember PHP
> starts counting at 0, so [1] is the second column or in your example
> "size"
> */
> function compare($x, $y )
> {
> if($x[1] == $y[1] )
> return 0;
> else if ($x[1] < $y[1])
> return -1;
> else return 1;
> }
>
> /* This is where the sorting takes place */
> usort($table_data, 'compare');
>
> /* This is where the results are output to the web page */
> for ( $row = 0; $row <3; $row++)
> {
> while ( list ( $key, $value ) = each( $table_data[$row]))
> {
> echo "\t $value";
> }
> echo '<br>';
> }
> ?>
> This should work for you. But you'll need to work out how to get the data
> in from a spread sheet or file.

Wow! u've almost done all the things, thx!! BTW, how to tell PHP which key
is to be used in the 'compare' function? and to facilitate automation, can
PHP interpret the following instead (add something like '\' to let it know
it's unfinished yet?) ?

$table_data= array(
(array ( 'a', 3, 5, 1, 10, 3, 'figA.gif' ))
,
(array ( 'b', 5, 2, 2, 4, 3, 'figB.gif' ))
,
(array ( 'c', 4, 3, 3, 9, 6, 'figC.gif'))
);

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация