Xoops modules development (1)

Source: Internet
Author: User
Tags what php
2. Compile the program in the region

False indicates the prototype architecture of xoops2 that you actually created in zookeeper, but you will compile some PHP programs. So, this method is suitable for you, you only need to compile your PHP program in the region, but you do not have to understand those patterns. Below we will explain it with a simple example.

Enter the management interface, and then go to the region Management page. There is an interface for adding a region. You only need to enter the PHP program repository in the "content" area. Remember! You do not need to merge the "<? PHP "or 「? > "The entire content must be a PHP program. If you need to show the text or HTML representation, you only need to use echo. For example:


Example 1. Compile the PHP program in the region Region

At the bottom of "Content Form", I remember to choose "php statement" and set the criteria of the region and where to find it, as shown in article 2, the results show the results of the PHP program we have built in our region.


Article 2. The intermediate region is the final result of the PHP program.

Of course, this example is based on the actual situation. It just takes a few minutes to capture the date and historical data, and then prints the data. The focus of this example is not what PHP requires, but that you only need to know that you can compile a PHP program in the region, you can even collect information in the region, and then sort out the information you have taken out. How to Use it depends on your experience!

2-1 configure the resource items in the region. If you want to use the xoops resource items, you can perform the following operations in the region:

$ Xoopsdb = & Database: getinstance ();
$ SQL = "select count (*) from". $ xoopsdb-> prefix ("users ");
$ Result = $ xoopsdb-> query ($ SQL );
List ($ count) = $ xoopsdb-> fetchrow ($ result );
Echo "Number of Members:". $ count;

Repeat this line:

$ Xoopsdb = & Database: getinstance ();

Create an xoops item.

$ SQL = "select count (*) from". $ xoopsdb-> prefix ("users ");

This is the SQL statement. In other words, you can find all the data from the users table. User is the member data table, and all data is the member data. In other words, this is a method for finding the number of all members.

$ Xoopsdb-> prefix ("users") refers to the frontend character to call the users table, because the xoops table has partial content, for example, if users is named xoops_user (xoops _ is the prefix) in the resource list, use $ xoopsdb-> prefix (" ") it will automatically add the front character.

$ Result = $ xoopsdb-> query ($ SQL );

Limit row SQL Limit Method

List ($ count) = $ xoopsdb-> fetchrow ($ result );

Use $ xoopsdb-> fetchrow to export the results of the rows, and then use List () to place the values column in the variable, because we only request one item (count (*), the list is placed in only one variable. If we request three items, so it should be list ($ var1, $ var2, $ var3 ).

Echo "Number of Members:". $ count;

Print the result that the area is about to be displayed.

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.