How much does it cost to build a personal website? Build a dynamic WML site 3

WBOY
Release: 2016-07-29 08:33:26
Original
808 people have browsed it

The user must then enter in the next file (index3.wml). We ask the user to enter the first name of the subject or the last name of the professor. You need to pay attention to how variables are transferred between pages. The syntax seems a bit complicated, but it gives you an idea of ​​how the entire process is accomplished through several files.
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">
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">
echo ("<POSTFIELD value='"$"."$choice".""/' name='"$choice"'>");
echo ("<POSTFIELD value='"$choice"/' name='"choice"'>");
? >
</CARD>
</WML>
Write query code
The following files are responsible for processing queries. Its name is query.wml and 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 querying 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";
$c>"subjects.Cod_Subject = teach.Cod_subject ";
// The following lines are used to construct SQL statements for 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.Room, exams.Test";
$exams_query= "exams.Cod_Subject = subjects.Cod_Subject ";
// The following lines are used to add query restrictions to the sql statement for querying 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 add query restrictions to the SQL statement for querying 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 ;
}
}
// Handle 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 of the teaching time
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 generates the wml code of the test timetable
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 when you select the teaching time or test time, connect to the database and call the wml code generated Function
if ($consulting_data) {
$connection_result =
connect($consulting_tables, $consulting_columns, $consulting_query);
consulting_print($connection_result);
}
if ($exams_data) {
$connection_resul t =
connect($exams_tables , $ exams_columns, $ exams_query);
print_exams($connection_result);
}
printf("</WML>n");
? >
 Okay, done.You have created your first PHP/WML page based on MySQL database. Continue to practice it yourself.​

The above introduces how much does it cost to build a personal website. How much does it cost to build a dynamic WML site? Part 3 includes the content of how much does it cost to build a personal website. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template