Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > seeking suggestion for posting spreadsheet data on web

Reply
Thread Tools

seeking suggestion for posting spreadsheet data on web

 
 
Ross
Guest
Posts: n/a
 
      08-22-2005
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.




 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      08-22-2005
With neither quill nor qualm, Ross quothed:

> 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.


Html per se has no functions for such programming. I'd suggest some
server-side scripting, such as PHP.

--
Neredbojias
Contrary to popular belief, it is believable.
 
Reply With Quote
 
 
 
 
Ross
Guest
Posts: n/a
 
      08-22-2005

"Neredbojias" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
>
> Html per se has no functions for such programming. I'd suggest some
> server-side scripting, such as PHP.
>

What keyword would you suggest me to have a look at PHP to see whether it is
really suitable before going deep in coding? thx for your response.


 
Reply With Quote
 
max
Guest
Posts: n/a
 
      08-22-2005
On Mon, 22 Aug 2005 16:25:29 +0800, "Ross" <(E-Mail Removed)> wrote:

>
>"Neredbojias" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed) m...
>>
>> Html per se has no functions for such programming. I'd suggest some
>> server-side scripting, such as PHP.
>>

>What keyword would you suggest me to have a look at PHP to see whether it is
>really suitable before going deep in coding? thx for your response.
>

Some of the more knowledgeable of the 7th Cavalry(!) may arrive shortly, but
until they do, try sticking
spreadsheet site:www.php.net
and
spreadsheet php
and
spreadsheet php.net
into google
If nothing else, some of the info there may help you decide which blind
alleys to avoid.
 
Reply With Quote
 
Rincewind
Guest
Posts: n/a
 
      08-22-2005
On Mon, 22 Aug 2005 10:23:07 GMT, max wrote:

> On Mon, 22 Aug 2005 16:25:29 +0800, "Ross" <(E-Mail Removed)> wrote:
>
> >
> >"Neredbojias" <(E-Mail Removed)> wrote in message
> >news:(E-Mail Removed) m...
> >>
> >> Html per se has no functions for such programming. I'd suggest some
> >> server-side scripting, such as PHP.
> >>

> >What keyword would you suggest me to have a look at PHP to see whether it is
> >really suitable before going deep in coding? thx for your response.
> >


Check out the PHP site www.php.net for multi dimensional arrays and for
createing arrays with spreadsheet output.
 
Reply With Quote
 
william
Guest
Posts: n/a
 
      08-22-2005
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.
 
Reply With Quote
 
Roy Schestowitz
Guest
Posts: n/a
 
      08-22-2005
On Monday 22 August 2005 04:20, 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.


Hi Ross,

I always prefer to think in terms of comma-separated values when handling
spreadsheets. Let us say that you use PHP and then pick one token at a time
with the intention of feeding it in to the database.

Thereafter, all you ought to do is create a database with tuples that
correspond to the columns of the table above. You should create some
meaningful functions (abstraction) to fetch column (value) given field
(row) and then work deeper to get more complex operations working. There
must be something like this lying around publicly, so don't re-invent the
wheel if possible. Do your homework before implementing anything.

To output the data, it would sensible in this particular case to place
everything in tables (Look ma! No divs!), e.g.

<table>
<tbody>
<tr>
<td>
A
</td>
<td>
3
</td>
<td>
6
</td>
<td>
1
</td>
<td>
10
</td>
<td>
3
</td>
<td>
<img src="figA.gif" alt="figA" />
</td>
</tr>
</tbody>
</table>


Hope it helps,

Roy

--
Roy S. Schestowitz Useless fact: Florida is bigger than England
http://Schestowitz.com
 
Reply With Quote
 
Ross
Guest
Posts: n/a
 
      08-22-2005
"william" <(E-Mail Removed)> wrote in message
news:39iv2tv2jz8h.1dhbcedlvgxop$(E-Mail Removed)...
> 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'))
);


 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      08-22-2005
Ross wrote:

> 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.


Down below are a couple of nice PHP functions that may be of use. I've
taken them from my CMS at work and munged them a little to make them
independent of it. I've not tested these munged ones, so they may need a
little adjusting.

Below the PHP code are some instructions on how they should be used.

<?php
function insert_datatable_cmp ($a, $b) {
return ($a[$_GET['sort']]<$b[$_GET['sort']]) ? -1 : 1;
}

function insert_datatable ($data, $headings, $options=array(), $caption='') {

if ($caption!='' && $options['h2']==1) print "<h2>$caption</h2>\n";
print "<table>\n";
if ($caption!='' && $options['h2']!=1) print "<caption>$caption</caption>\n";
print "<thead><tr>";
$i = 0;
foreach ($headings as $h) {
print "<th scope=\"col\"><a href=\"${_SERVER['PHP_SELF']}?sort=$i\">$h</a></th>";
$i++;
}
print "</tr></thead>\n<tbody>\n";

$lines = explode("\n",$data);
$i = 0;
while ($l = array_shift($lines)) {
$s[$i++] = explode("|",$l);
}

if(isset($_GET['sort'])) {
usort($s,"insert_datatable_cmp");
}

foreach ($s as $S) {
print "<tr>";
for($i=0;$S[$i];$i++)
{
if ($options['email:'.$i]==1)
{
$S[$i] = '<a href="mailto:' . $S[$i] . '">' . $S[$i] . '</a>';
} elseif ($options['web:'.$i]==1)
{
$S[$i] = '<a href="' . $S[$i] . '">' . $S[$i] . '</a>';
}

if ($options['join:'.$i.':'.($i+1)]==1)
{
print '<td colspan="2">' . $S[$i] . ' ' . $S[$i+1] . '</td>';
$i++;
}
else
{
print '<td>' . $S[$i] . '</td>';
}
}
print "</tr>\n";
}

print "</tbody></table>\n";

}
?>

To create the table you posted, you would do this:

<?php
$d = "A|3|5|1|10|3|figA.gif
B|5|2|2|4|3|figB.gif
C|4|3|3|9|6|figC.gif";

$h = array('name','size','length','0min','3min','10min' ,'chart');
$o = array('web:6'=>1);
$c = 'My Caption';

insert_datatable($d, $h, $o, $c);
?>

As you can see, the first argument for the insert_datatable() function is
a pipe-seperated table of data. The second argument is a PHP array of
headings. The third argument is an array of "options" (explained later).
The last argument is a caption for the table. The first two arguments are
required. The last two are optional. (But if you include a caption, you
must also include the options array!)

The options are set like this:
$o = array('option1'=>1, 'option2'=>1, 'option3'=>1);
so that the "=>1" means "switch this option on".

What options can be used? "web:X" means that column number X is a web
link. "email:X" means that column X is an e-mail address. "join:X:Y" means
that columns X and Y should be joined (useful if X is a person's first
name and Y is their surname!). Column numbers start from 0, not 1.

That's about it!

Copyright: 2005 Toby Inkster. You may use the above in your own projects,
under the terms of the GNU GPL. http://www.gnu.org/copyleft/gpl.html

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
william
Guest
Posts: n/a
 
      08-22-2005
On Mon, 22 Aug 2005 23:37:26 +0800, Ross wrote:

> "william" <(E-Mail Removed)> wrote in message
> news:39iv2tv2jz8h.1dhbcedlvgxop$(E-Mail Removed)...
>> 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?


this is just one way of doing it, what you need to do is create a form to
enter which column to sort by, if you look at the compare function you'll
see I've already said which part to change to sort by a different row. so
what you have to work out is how to replace the number betweem the square
brackets with a string that you pass through the form.

> and to facilitate automation, can
> PHP interpret the following instead (add something like '\' to let it know
> it's unfinished yet?) ?


I presume you mean the entereng of data? if so then you need to look at the
php manual for inserting spreadsheet data as arrays.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Posting Fails in Medium Trust (3rd time posting this w/ zero replies so far) AmitKu ASP .Net 7 01-08-2007 07:31 PM
Top Posting vs. Bottom Posting scaredkitty Computer Support 37 04-06-2005 12:27 AM
System.Data.OleDb.OleDbException: Could not find installable ISAM : Read Excel Spreadsheet in web-form Roger Twomey ASP .Net 1 04-27-2004 09:12 PM
Seeking Suggestion Nice Chap ASP .Net 2 04-27-2004 02:05 PM
Everytime I hover cursro over a posting, it crosses out with red mark on it.. on every posting alanb ASP .Net 2 04-23-2004 02:23 PM



Advertisments