On the output method of two kinds of database content HTML format

Source: Internet
Author: User
Tags format copy query
In the practical application of VFP to write a variety of application system process, users may establish a large number of data information, which is generally stored in various types of data tables, with the rapid development of network technology, many data information requirements on the Internet to share the use, if the relevant information already exists in the datasheet, you can not need to re-enter the information, Directly generates HTML format files that can be browsed on the Web, the following article introduces two methods of database content to HTML format output.

One, the use of VFP provided data table content conversion to the HTML format file class library implementation. There is a _INTERNET.VCX class library in the FFC subdirectory of VFP system, in which _dbf2html is the conversion class for datasheet to HTML format, when used, you can add the class library to the control by using the method of adding the class in the Form control window and add _ to the form. Dbf2html class, which describes the properties, events, and methods described below:

The Csource property indicates the data table source file name that generated the HTML, and the default value is "".

Ngenoutput Property _genhtml Output option

0-Generate output file

1-Generate the output file and display it in the Visual FoxPro editor

2-Generate output file and display it in Internet Explorer editor

3-Generate and display the output file after the Save As dialog box is displayed

4-Create a Public_ohtml object and generate a file

5-Creating a Public_ohtml object does not generate a file

The default value is 2

The Coutfile property indicates the name of the output HTML file, and the default value is ""

The Iautonameoutput property indicates whether _genhtml automatically commands the output file based on the source, and the default value is. T..

The Iusecurrentalias property indicates whether the current alias is used as the source, and the default value is. T..

The Cscope property indicates the scope of the output (example good next or all), and the default value is "".

The Cstyle property indicates the visual style listed in the GENHTML.DBF ID field, and the default value is "".

The Genhtml method calls by using the properties specified in Csource, Coutpur, and Ngenoutput

GENHTML.PRG to generate HTML code

Syntax: genhtml ()

return value: None

Parameters: None

If there is a basic data table for cadres on the disk, we can use the class library described above to automatically format the data in the person's communication record.

Create a new form that uses the form control class to add the _internet.vcx class library to the form, click the _dbf2html class to add to the form, set the class Name property to En, the other properties are the default, and then add a command button to the form COMMAND1. Add the following code to the click event of the command button:

File1=getfile ("DBF") && Select a datasheet file

File2=subs (File1,1,at (".", FILE1)-1) && remove filename suffix

File2=subs (File2,rat ("\", FILE2) +1) && Remove the path to the filename

IF USED ("&file2")

Sele &file2

ELSE

Sele 0

Use &file2

ENDIF

&& the above command is to confirm that a data file has been opened

Thisform.zh. Genhtml () && Execute the conversion program

Save and run this form, use the mouse to click on the command button in the window, will pop up a selection file dialog box, where you can select a data table file, we select the Personnel Communications data table, determined to find, The system will automatically generate a Web page file with the same name as the HTM file in the selected datasheet and launch the browser to browse the generated HTM file to achieve the output of the HTML file for the database content.

Second, the application of FrontPage2000 Web page editing tools and VFP system programming skills to achieve, the previous method generated HTML format file is in tabular form, each behavior of a record, when the database of too many fields, browsing the generated HTML format file is very inconvenient. In practice, it is often necessary to generate a custom table-style HTML format file for one person's situation, which can not be achieved by using the method provided above. Can take the application of FrontPage2000 Web page editing tools and VFP system programming skills combined to achieve a variety of Web page file generation output requirements.

First, using the FrontPage2000 Editing Tool, edit a WYSIWYG static page, and eventually edit the page as follows:

In this web page designer, the resulting table is preceded with a # #的字符为所在生成网页格式数据来源中的数据库中的字段名称, such as a # #姓名, where the name is the field name in the database. To view the HTML source file, we select all of the source files and then copy them.

Create a new database to hold the Web page format content, which is named LSK.DBF, with only one field named Htmlnr in the database and a memo type. Add an empty record to the database, and then open the Memo field Htmlnr into the edit window state, and then perform the paste operation to copy the contents of the FrontPage2000 generated Web page format source file to the Memo field, so a well-designed Web page format library is generated, Here you can also generate a large number of different forms of Web page content stored in the database for any time to generate web use, here we take a style for example.

To write a conversion program, the main principle of the program is to open the LSK database, take out the format of the generated Web page string content, open the need to output the basic situation of the Cadre database file, with the corresponding field in the database replacement page format with # #为标识的字段串内容, all the field content replaced, Finally, the text of the format generated an HTML file, you can complete the system requirements, the program is written as follows:

Use LSK && open web page format Content Library

Zynr=htmlnr && take out a Web page format content text

Use Ryk && Open the database where you want to generate a Web page

Zynr=strtran (Zynr, "# #姓名", Ryk. Name)

Zynr=strtran (Zynr, "# #性别", Ryk. Gender)

&& because character substitution functions can only use character types, date and number types must be converted

Zynr=strtran (Zynr, "# #出生年月", STR (Year (Ryk)) + '. ' +str (MONT (Ryk)) + '. ' +str (Ryk.))

Zynr=strtran (Zynr, "# #曾用名", Ryk.)

Zynr=strtran (Zynr, "# #民族", Ryk.)

Zynr=strtran (Zynr, "# #工作年月", STR (Ryk. Working years)) + '. ' +str (MONT (Ryk)) + '. ' +str (Ryk.))

Zynr=strtran (Zynr, "# #入学时间", STR (Ryk. Admission time)) + '. ' +str (MONT (Ryk time)) + '. ' +str (Day (Ryk. Admission time))

Zynr=strtran (Zynr, "# #毕业时间", STR (Ryk. Graduation)) + '. ' +str (MONT (Ryk. Graduation)) + '. ' +str (Ryk. Graduation time))

Zynr=strtran (Zynr, "# #毕业院校", Ryk. Graduated college)

Zynr=strtran (Zynr, "# #学历", Ryk.)

Zynr=strtran (Zynr, "# #所学专业", Ryk.)

Zynr=strtran (Zynr, "# #家庭住址", Ryk. Home address)

Zynr=strtran (Zynr, "# #邮政编码", Ryk. zip code)

Zynr=strtran (Zynr, "# #家庭电话", Ryk. Home phone)

Zynr=strtran (Zynr, "# #家庭电话", Ryk. Home phone)

Zynr=strtran (Zynr, "# #手机号", Ryk. Mobile number)

Zynr=strtran (Zynr, "# #工作单位", Ryk. Work unit)

Zynr=strtran (Zynr, "# #现任何职", Ryk. Now any grade)

Zynr=strtran (Zynr, "# #个人简历", Ryk. Personal resume)

&& Replace all, generate an HTML file for the final result

=strtofile (Zynr, ' ABC. HTM ')

Use Ryk

Execute this program, will automatically generate a name abc.htm file, in the browser to view the file, the file appears as follows:

We found that the content in the relevant fields in the database becomes the content of the page, so it is very convenient to achieve the output of the content in the database to the Web page format file. In the actual application process, can also be designed to generate a large number of different styles of Web page storage in the database, the use of this library to easily achieve the output of various types of Web pages, expanding the scope of the application of database data content.

The above two methods can be used according to different requirements, in the implementation of the application can also be in the database to perform the query operation, and then the results of the query generated Web browsing, the application method will be more flexible, interested readers may wish to try.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.