如何从本地文本文件填充HTML表。 [英] How to populate HTML table from local text file.

查看:70
本文介绍了如何从本地文本文件填充HTML表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在寻找一种从外部

本地文本文件填充HTML表格的方法,如下所示:


日期/时间。 LON。深度。 ML。

-------------------- ---------- ---------- ------- -------

21/03 / 2005-04:06:03 XX,XX XX,XX 171 3,42

21/03 / 2005-12:23:53 XX,XX XX,XX 500 5,4

21/03 / 2005-12:43:10 XX,XX XX,XX 553 5, 38

21/03 / 2005-18:47:51 XX,XX XX,XX 162 3,91

21/03 / 2005-19:29:49 XX ,XX XX,XX 500 3,51

21/03 / 2005-20:04:51 XX,XX X,X 75 3,72


该文件可能有更多行(DATA),我在这里显示。该文件是每天提供给我的
,我必须每天更新一个网页

以及该文件的内容。


我考虑使用嵌入在HTML页面中的JavaScript,但我是一个

新手关于它引用的网页脚本。


我怎么能用这个文本文件填充HTML表格,每天更改




另外,是否可以只使用php客户端,没有服务器?


您的帮助,建议和反馈意见将很多

赞赏。


谢谢。


Alex。

解决方案

alex(al ************** @ hotmail。 com)写道:




:我正在寻找一种从外部填充HTML表格的方法

:本地文本文件,如下所示:


:DATE / TIME LAT。 LON。深度。 ML。

:-------------------- ---------- --------- - ------- -------

:21/03 / 2005-04:06:03 XX,XX XX,XX 171 3,42

:21/03 / 2005-12:23:53 XX,XX XX,XX 500 5,4

:21/03 / 2005-12:43:10 XX,XX XX, XX 553 5,38

:21/03 / 2005-18:47:51 XX,XX XX,XX 162 3,91

:21/03 / 2005- 19:29:49 XX,XX XX,XX 500 3,51

:21/03 / 2005-20:04:51 XX,XX X,X 75 3,72


绝对最简单的方法就是用< pre>

< / pre>简单地包装上面的文字。标签。


< html>

< head> <标题> 2005年3月21日的数据< / title> < / head>

< body>

< pre>

日期/时间拉特。 LON。深度。 ML。

-------------------- ---------- ---------- ------- -------

21/03 / 2005-04:06:03 XX,XX XX,XX 171 3,42

21/03 / 2005-12:23:53 XX,XX XX,XX 500 5,4

< / pre>

< / body>

< / html>


-


这个空间不用于出租。

Malcolm Dew-Jones写道:

alex(al**************@hotmail.com)写道:

:我正在寻找一种从外部填充HTML表格的方法:
本地文本文件,如下所示:

(knip)

绝对最简单的方法就是用
< pre>简单地包装上面的文字。 < /预>标签。




那不是HTML表......:S


使用服务器端的php'不是那么难。你可以每天只生成一次HTML

表,或者总是动态...


读取文件,拆分列,并生成一些表格代码,而

将值放入其中。


这是一个如何读取文件的例子。这个创建一个包含所有值的数组

,但当然你可以直接打印table-html。


< pre>

<?php


handle = fopen(" ./ data.txt",''r'');

Hi,

I am looking for a way to populate an HTML table from an external
local text file which looks like this:

DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
21/03/2005-18:47:51 XX,XX XX,XX 162 3,91
21/03/2005-19:29:49 XX,XX XX,XX 500 3,51
21/03/2005-20:04:51 XX,XX X,X 75 3,72

The file could have more rows (DATA) that I show here. The file is
provided to me on a daily basis and I have to update a web page daily
with the contents of the file.

I considered using JavaScript embedded in the HTML page but I am a
newbie on what scripting for the web it refers.

How can I populate the HTML table with this text file which changes
everyday.

Also, is it possible to use php client-side only, without a server?

Your help, suggestions and feedback questions will be much
appreciated.

Thanks.

Alex.

解决方案

alex (al**************@hotmail.com) wrote:
: Hi,

: I am looking for a way to populate an HTML table from an external
: local text file which looks like this:

: DATE/TIME LAT. LON. DEPTH. ML.
: -------------------- ---------- ---------- ------- -------
: 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
: 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
: 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
: 21/03/2005-18:47:51 XX,XX XX,XX 162 3,91
: 21/03/2005-19:29:49 XX,XX XX,XX 500 3,51
: 21/03/2005-20:04:51 XX,XX X,X 75 3,72

the absolutely easiest way is to simply wrap the above text with the <pre>
</pre> tags.

<html>
<head> <title> data from 21/03/2005 </title> </head>
<body>
<pre>
DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
</pre>
</body>
</html>

--

This space not for rent.


Malcolm Dew-Jones wrote:

alex (al**************@hotmail.com) wrote: : Hi,

: I am looking for a way to populate an HTML table from an external :
local text file which looks like this:

(knip)

the absolutely easiest way is to simply wrap the above text with the
<pre> </pre> tags.



That''s not an HTML table... :S

Using server-side php it''s not that difficult. You can generate the HTML
table only one-a-day, or always on the fly...

Read the file, split up the colums, and generate some table code, while
putting the values in it.

Here''s one example how you can read the file. This one creates an array
with all the values, but of course you can print the table-html directly.

<pre>
<?php


handle = fopen("./data.txt", ''r'');


这篇关于如何从本地文本文件填充HTML表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆