Create a dynamic WML site (3 ). Then, you must enter it in the next file (index3.wml. We ask the user to enter the subject name or the professor's surname. Pay attention to how variables are transmitted between pages. Then, you must enter it in the next file (index3.wml. We ask the user to enter the subject name or the professor's surname. Pay attention to how variables are transmitted between pages. The syntax seems a bit complex, but it helps you understand how the entire process is completed 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'?>; ");
>;
<! DOCTYPE wml PUBLIC "-// WAPFORUM // dtd wml 1.1 // EN"
"Http://www.wapforum.org/DTD/wml_1.1.xml" >;< WML>
<CARD id = card3 title = Name>
<? Php
Echo ("<p> Insert ");
If ($ {$ choice }== "surname "){
Echo ("partition Sor's surname (or part of it). n ");
} Else if ($ {$ choice }== "subject "){
Echo ("the subject (or part of it). n ");
} Else {
Echo ("Maybe there is some problem. n ");
} Echo ("<INPUT name = '" $ {$ choice} "'type ='" text "'> ");
?>
<DO type = "text" label = "Go">
<GO href = "query. wml" method = "get">
<? Php
Echo ("<POSTFIELD value = '" $ "." $ choice "." "/'name ='" $ choice "'> ");
Echo ("<POSTFIELD value = '" $ "." $ {$ choice} "." "/'name ='" $ {$ choice} "'> ");
?>
</GO>
</DO>
<P> </P>
</CARD>
</WML>
<DO type = "text" label = "Go">
<GO href = "index3.wml # card3" method = "get">
<? Php
Echo ("<POSTFIELD value = '" $ "." $ choice "." "/'name ='" $ choice "'> ");
Echo ("<POSTFIELD value = '" $ choice "/'name ='" choice "'> ");
?>
</CARD>
</WML>
Write query code
The following files process queries. Its name is query. wml. we will analyze it in more detail.
<? Php
Header ("Content-type: text/vnd. wap. wml ");
Printf ("<? Xml version = "1.0"?> N ");
Printf ("n ");
Printf ("n ");
// The following lines are used to construct SQL statements for query teaching time
$ Consulting_tables =
"(Professors left join teach on (professors. Id = teach. Id), subjects )";
$ Consulting_columns =
"Professors. Surname, professors. Name, subjects. Subject ,";
$ Consulting_columns. =
"Subjects. Cod_number, professors. Consulting_hour, professors. Consulting_place ";
$ Consulting_query =
"Subjects. Cod_Subject = teach. Cod_subject ";
// The following lines are used to construct an SQL statement for the query time
$ Exams_tables = "(exams left join professors ON (exams. Id = professors. Id), subjects )";
$ Exams_columns = "subjects. Subject, subjects. Cod_number, professors. Surname ,";
$ Exams_columns. = "professors. Name, exams. Date, exams. Time, exams. Room, exams. Test ";
$ Exams_query = "exams. Cod_Subject = subjects. Cod_Subject ";
// The following rows are SQL statements used to query the test time table to add query restrictions.
If ($ exams_data ){
Switch ($ exams_data ){
Case "subject ":
$ Exams_query. = "and subjects. Subject like '% $ subject % '";
Break;
Case "surname ":
$ Exams_query. = "and professors. Surname like '% $ surname % '";
Break;
}
}
// The following rows are used to add query restrictions for SQL statements that query the teaching time.
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_passed order by professors. Surname ";
$ Result = mysql_query ($ SQL, $ db );
Return $ result;
}
// This function generates the wml code for the teaching time
Function consulting_print ($ consulting_result ){
Global $ file;
Printf ("n ");
Printf ("<P> copying ing hours
N ");
While ($ myrow = mysql_fetch_row ($ consulting_result )){
Printf ("<P> $ myrow [0], $ myrow [1] </P> n ");
Printf ("<P> $ myrow [2] </P> n ");
Printf ("<P> $ myrow [3] </P> n ");
Printf ("<P> $ myrow [4] </P> n ");
Printf ("<P> $ 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 ("<CARD id = '" card1 "'title ='" hours "'> n ");
Printf ("<P> Examinations hours
N ");
While ($ myrow = mysql_fetch_row ($ exams_result )){
Printf ("<P> $ myrow [2], $ myrow [3] </P> n ");
Printf ("<P> $ myrow [0] </P> n ");
Printf ("<P> $ myrow [1] </P> n ");
Printf ("<P> $ myrow [4], $ myrow [5] </P> n ");
Printf ("<P> $ myrow [7] </P> n ");
Printf ("<P> $ myrow [6] </P> n ");
}
Printf ("</CARD> n ");
}
// Check whether you select the teaching time or test time to connect to the database and call the function that generates wml code.
If ($ consulting_data ){
$ Connection_result =
Connect ($ consulting_tables, $ consulting_columns, $ consulting_query );
Consulting_print ($ connection_result );
}
If ($ exams_data ){
$ Connection_result =
Connect ($ exams_tables, $ exams_columns, $ exams_query );
Print_exams ($ connection_result );
}
Printf ("</WML> n ");
?>
Okay, it's done. You have created the first PHP/WML page based on the MySQL database. continue with the practice.
Parameters (index3.wml. We ask the user to enter the subject name or the professor's surname. You should pay attention to how variables are transmitted between pages ....