帮助使用PHP文件从mysql&读取数据写出Html [英] Help to use PHP file to read in data from mysql & write out Html

查看:56
本文介绍了帮助使用PHP文件从mysql&读取数据写出Html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

O.K。这是一个很长的标题...

你能帮我/告诉我怎么样.........我会长时间地试着画这幅画。

Backround:我有一个html页面,里面有一个选框功能,可以在网页上的框中显示一张小照片和其他信息。

marquee'的信息是一个包含数据的表格,我现在手动插入。

我希望能够从mysql数据库中插入数据。

选框通过阅读我命名的< DIV>中包含的任何内容来工作。

DIV内部是带有数据的格式化表格。

我想用数据库中的数据填充这些DIV,并编写一个可以包含在主页面中的输出文件......在加载主页面之前。换句话说,由于在加载时尝试读取数据,我不希望主页面加载缓慢。

我不介意手动做一些后端的PhP文件来获取这个文件写好并准备就绪,以便在准备好时读取主页面。

我需要输出的文件只是DIV语句,表格和单元格格式已经完成,只需将数据插入到正确的细胞....像这样......

< DIV>< table>< tr>< td> Http://smallpicture.jpg< td>< tr>

< tr>< td> DATA1 Stuff< td>< td> DATA2 Stuff< td>< tr>

< tr>< tdDATA3 Stuff< td>< tr>< table>

< / DIV>

然后另一个< DIV>并且尽可能多地读取可能是10个项目或DiV'的数据库。

如果我可以写入该文件,那么我可以将它包含在marquee文件中IF-进入网页。

感谢您的帮助。

O.K. that was a long Title...
Can you help / show me how I would......... I am going to long windedly try to paint this picture.
Backround: I have an html page that has a marquee function in it to display a small photo and other information to scroll in a box on the web page.
The marquee''s info is a table with data that I now insert manually.
I would like to be able to insert the data into it from a mysql database.
The marquee works by reading anything that is enclosed in my named <DIV>''s.
Inside the DIV''s is the formatted table with the data.
I would like to populate these DIV''s with the data from the database and write an output file that can be included into the main page... BEFORE the main page is loaded. In other words I do not want the main page to be slow in loading due to trying to read the data as it loads.
I would not mind doing a little back end PhP file stuff manually just to get this file written and in place for the main page to read when ready.
The file that I need to output is just DIV statements with the table and cell formats already done just needing the data inserted into the proper cells....Like this....
<DIV><table><tr><td>Http://smallpicture.jpg<td><tr>
<tr><td>DATA1 Stuff<td><td>DATA2 Stuff<td><tr>
<tr><tdDATA3 Stuff<td><tr><table>
</DIV>
Then another <DIV> and as many as it takes to read the data base which may be 10 items or DiV''s woth.
If I can get that file written then I can include it into the marquee file which will be IFramed into the web page.
Thanks for any help.

推荐答案

嗨。欢迎来到TSDN!


这听起来非常可行。

实际上,你可能正在描述今天使用的所有PHP代码中99%的设计:)


如果您的唯一目标是获取MySQL表格并将其显示为HTML,您可以使用以下简单的内容:
Hi. Welcome to TSDN!

This sounds very doable.
In fact, you could be describing the design of 99% of all PHP code in use today :)

If your only goal is to take a MySQL table and display it as HTML, you could use something as simple as:
展开 | 选择 | Wrap | 行号


感谢您的回复。

但是,我试图将数据合并到已经详细的格式化表中。但是现在看一下你输入的内容并再考虑一下,我想我必须让PHP回显所有那些表语句才能获得最多10个DIV语句。

我当时想要能够制作一个锅炉板格式化的表格,并且php将选定的字段放入正确的单元格中。但那么如何旋转最多10条记录呢? hmmmm。我想我正在考虑数据库会在纸上打印这些东西。

OK ....

假设我有一张名为ADDRESS的表

我有名为Fields = PHOTO,NAME,STREET,CITY,STATE,ZIP

我有一张表来包含这些信息。

< DIV>

| ~~~~~~~~~~~~~~~~~~~~~~~~~~

|插入PHOTO字段------------ |

| |

| ----------------------------------------- --------- |

|插入NAME字段|

------------------------------------------ -------- |

| STREET Field |

------------------------------------------ -------- |

| CITY ------ | STATE -------- | ZIP ----------- |

----------------------------- --------------------- |< / DIV>

所以你说我必须回应所有的Div和表格信息?

将这些数据字段放在其位置的命令或语法是什么。

已经很晚了,我现在可能在胡言乱语。但是如果你认为你知道我的意思那就让我知道。
Thanks for responding.
However, I was trying to just merge the data into an already detailed formatted table. But now looking at what you typed in and thinking about it a little more, I guess I would have to have the PHP echo all those table statements to get the up to 10 DIV statements produced.
I was thinking to be able to just have a boiler plate formatted table made up and the php drop the selected fields into the proper cells. But then how would that rotate through the up to 10 records? hmmmm. I guess I''m thinking like the database is going to print this stuff out on paper.
O.K.....
Lets say I have a table named ADDRESS
and I have the named Fields = PHOTO, NAME, STREET, CITY, STATE, ZIP
and I have a table to include this info.
<DIV>
|~~~~~~~~~~~~~~~~~~~~~~~~~|
| Insert PHOTO Field ------------ |
| |
|--------------------------------------------------|
| Insert NAME Field |
--------------------------------------------------|
| STREET Field |
--------------------------------------------------|
| CITY------| STATE--------| ZIP----------- |
--------------------------------------------------|</DIV>
So you are saying that I have to echo all the Div and table info?
What are the commands or the syntax to place these Data Fields in their places.
its late and I may be babbling on now. but if you think you know what I mean then let me know.


我想我知道你的意思......你想先把桌子放好,然后把所有的值放进去它。这不是真的可能(好吧可能是这样,但只是以一种非常奇怪和无用的复杂方式!)。我认为你应该采用上面显示的方法。你总是可以在while循环之前添加一个表行,其中包含表头,如果你想在表底部有任何东西,也可以在底部的while()循环之后添加。
I think I know what you mean... You want to make the table first, and THEN put all the values into it. That''s not really possible (well it might be, but only in a very odd and pontless complex way!). I think you should go with the method shown above. You can always add a table row before the while loop with the table headers in it, and similarly after the while() loop at the bottom if you want anything at the base of the table.


这篇关于帮助使用PHP文件从mysql&amp;读取数据写出Html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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