How much does it cost to build a personal website? Creating a dynamic WML site three

Source: Internet
Author: User
The user must then enter in the next file (INDEX3.WML). We ask the user to enter the name of the subject or the professor's surname. You should be aware of how variables are routed between pages. The syntax seems a little complicated, but it lets 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 '? >; ");
>
! 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 ("Professor ' 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 are responsible for processing the query. Its name is QUERY.WML, and we will analyze it in more detail.
<? Php
Header ("CONTENT-TYPE:TEXT/VND.WAP.WML");
printf ("&LT;? XML version= "1.0"? >n ");
printf ("n");
printf ("n");
The following lines are used to construct the SQL statement for the query class 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 ";
$c > "subjects. Cod_subject = teach. Cod_subject ";
The following lines are used to construct the SQL statement for the query test 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. The exams. Test ";
$exams _query= "exams. Cod_subject = subjects. Cod_subject ";
The following lines are used to increase the query limit for SQL statements that query the test schedule
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 lines are used to increase the query limit 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
}
}
Handling connections to a 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 duration of the lesson
function Consulting_print ($consulting _result) {
Global $file;
printf ("n");
printf ("<p> Receiving 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 produces a WML code for the quiz schedule
function Print_exams ($exams _result) {
Global $file;
printf ("<card 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 if you choose a class or quiz time, connect to the database and invoke the function that generated the 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");
? >
Well, it's done. You've set up your first MySQL database-based PHP/WML page, so keep practicing.

The above describes how to build a personal website how much money to build a dynamic WML site three, including the establishment of personal site how much content, I hope to be interested in PHP tutorial friends helpful.

  • 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.