Mobile phones that support WAP feature have more and more. Therefore, you should also consider establishing your own WML website. This article is to introduce the site of how to establish a PHP / WML page, use the MySQL database, the content of the site, the specific example is a teaching time of a college, Quiz timetable. Little is not complicated :-)
Before you start, you should be ready for the following stuff:
1. You have installed PHP and MySQL correctly, and there are experiences that use both. 2. You have SQL related knowledge 3. You run apache and write .haccess files; or you can run IIS and you can increase mapping (or you can help you for your system); 4. You have WML Related knowledge;
Ok, the first step will first let your server know using PHP to handle the WML file, the following describes how to do this.
Set the server
If you are using Apache, you must find a .haccess file in your directory. Then add the following line:
AddType Application / X-httpd-php3 .wml
If you can't find the file, you can join one and join the above line, put it in your directory.
If you are using IIS, you have to make some changes, almost when you install PHP: Take a look at the .php and .php3 extension mapping, and add the same mapping process for .wml.
Usually you will find PHP being mapped to:
C: / php/php4isapi.dll
or
C: / php/php.exe
Ready to work
If you are using Microsoft's operating system, you can install Nokia's development kits. It can check your grammar and let you preview the WML page through an image-like interface, which also has a reference documentation for WML and WML scripts. If your phone doesn't have WAP support, or you can't use a WAP gateway, this can help it.
To download this tool, you must first register with a WAP developer (http://www.forum.nokia.com/main/0, 6668, 1_1_4, 00.html), to remember You need Java2 Runtime Enviroment support (support for Java2 running environment). You can write the page with any text editor.
Before writing any PHP / WML code, you need to build the MySQL form.
The database is composed of 4 tables.
1. Professors table includes professor-related data; SubjuctS table includes related data for the subject; 3.Exams table includes related data related to the test; 4.Teach table includes professor and the relationship information they areicker
When connecting MySQL, you can create a table through the following code.
CREATE TABLE professors (Id int (11) DEFAULT '0' NOT NULL auto_increment, Surname varchar (24) NOT NULL, Name varchar (24) NOT NULL, Email varchar (48) DEFAULT 'Not avaliable', Cod_course varchar (16) DEFAULT 'Not avaliable', consulting_HOUR VARCHAR (128) Default 'not avaliable', consulting_place varchar (128) Default 'Not Avaliable', Primary Key (ID)); these statements have established a table structure of Professors. The ID is assigned a unique identifier to each professor and is the primary key of the table. Other fields, Surname, Name, email are used to represent each professor's last name, name, and E-mail address. COD_COURSE is the only identified value of each subject. Finally, consulting_HOUR and CONSULTING_PLACE indicate a location and lecture.
Create Table Subjects (Subject Varchar (96) Not Null, COD_SUBJECT VARCHAR (24) Not Null, COD_NUMBER VARCHAR (12) Not Null, Primary Key (COD_SUBJECT));
Subject is the name of the subject, COD_SUBJECT is the name of each subject using the college, and its value is unique and is the primary key of this table. COD_NUMBER is a number of fields, and different courses of the same subject belong to a group. This number is the identifier number of the group.
Create Table Exams (COD_SUBJECT VARCHAR (24) Not Null, ID INT (11) Not Null, Date Date Default '0000-00-00', Time Time Default '00: 00: 00', Room Varchar (64), Test Varchar (16) Default 'oral');
COD_SUBJECT refers to the name of each subject representing the college. The only ID is the only identifier number, Date, Time and Room used to record the date, time and place of the test, Test used to indicate the type of test (including Written, verbal, etc.)
Create Table Teach (COD_SUBJECT VARCHAR (16) Not Null, ID INT (11) Default '0' Not Null, Primary Key (ID, COD_SUBJECT));
In the TEACH table, the ID is the professor's identification number, the meaning of COD_SUBJECT, and the two constitute the primary key of the table.
The next step is to fill in some data in the database, which can be done by itself.
Write PHP / WML code
Now we write the first PHP / WML page, named index.wml
PHP
Header ("Content-Type: TEXT / VND.WAP.WML"); Header ("Cache-Control: No-Cache, Must-revALIDATE"); Header ("Pragma: no-cache"); echo (" XML Version = '1.0'?> ");? >
"http://www.wapforum.org/dtd/wml_1.1.xml"> you can search for professors' Consulting Hours or for Examations Timetables. Check if the PHP has a short label support. If so, can you do a similar XML Version = '1.0'? > The statement and nested it into the PHP code to avoid confusion. The remaining code of this page is just the time or consultation of your test. The selected item will be recorded in the $ choice variable. The next page is called index2.wml, so that you choose to query the database through the subject or last name. Header ("Content-Type: TEXT / VND.WAP.WML"); Header ("Cache-Control: No-Cache, Must-revALIDATE"); Header ("Pragma: no-cache"); echo (" XML Version = '1.0'?> ");? > "http://www.wapforum.org/dtd/wml_1.1.xml"> IF ($ choice == "exams_data) {echo (" examinations Timetables. The user must enter in the next file (INDEX3.WML). We ask users to enter the name of the subject or the professor's last name. You have to pay attention to how the variable is transmitted between the page. The syntax seems to be a bit complicated, but you can let you know how the whole process is done through several files. PHP Header ("Content-Type: Text / Vnd.wap.wml"); Header ("Cache-Control: No-Cache, Must-revALIDATE"); Header ("Pragma: no-cache"); ECHO ("< XML Version = '1.0'?>; ");>; ; insert"); if ($ $ choice} == "weak") {echo ("Professor's Surname (or part of it) ./ n");} else f ($ {h c } == "Subject") {echo ("The Subject (or Part of It) ./ N");} else {echo ("Maybe there is some problemm./n");} echo (""); Echo (" ? > Go> do> p> cours> wml> if ($ consulting_data) {switch ($ consulting_data) {case "subject": $ consulting_query = "and subjects.Subject like '% $ subject%'"; break; case "surname":. $ consulting_query = "and professors.. Surname Like '% $ Surname%' "; BREAK;}} // Process the connection to the database Function Connect ($ TABLES, $ DATA, $ CONDition_Passed) {// Put Your Password And UserName in Next Line // $ db = mysql_pconnect ("localhost", "***", "***"); // put your database name in Next Line mysql_select_db ("lanfranchi_co_uk", $ dB); $ SQL = "SELECT $ DATA from $ TABLES where $ condition_parassed Order by Professors.Surname"; $ Result = mysql_query ($ SQL, $ dB); Return $ Result;} // This function produces WML code for teaching time Function Consulting_Print ($ consulting_result) {global $ file; printf ("/ n"); printf (" receiving hours / N "); while ($ myrow = mysql_fetch_row ($ consulting_result)) {printf (" $ myrow [0], $ myrow [1] p> / n "); Printf (" $ MYROW [2] p> / n "); Printf (" $ myrow [3] p> / n "); Printf (" $ myrow [4] p> / n "); Printf (" $ myrow [5] p> / n ");} Printf (" card> / n ");} // This function generates the WML code for the test schedule Function print_exams ($ exams_result) {global $ file; printf ("
PHP ECHO ("You are Checking");
/ n ");} else f ($ choice ==" consulting_data) {echo ("consulting hours.
/ n" );
} else {
ECHO ("I don't know what and there is some problem.
/ n");}? >
You can search by surname (either exact or partial) or by subject (either exact or partial).
Select the kind of research.