接著使用者必須在下一個檔案(index3.wml)中輸入。我們要求使用者輸入科目的名字或教授的姓。你要留意一下變數在頁面之間是怎麼傳送的。文法看來有點複雜,不過可以讓你了解整個過程是怎麼透過幾個檔案來完成的。
Header("Content-type: text/vnd.wap.wml");
header("Cache-Control: no-cache, must-revalidate"); no
header("Pragma:er("Pragma:)("Pragma: -cache");
echo ("<?xml version='1.0'?>;");
>;
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD/ML 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> ="Go">
<GO href="index3.wml#card3" method="get">
echo ("<POSTFIELD value='"$"."$choice".""/' name='"$choice"'>");
echo ("<POSTFIELD value='"$ choice"/' name='"choice"'>");
? >
</CARD>
</WML>
寫查詢程式碼
以下的文件負責處理查詢。它的名字是query.wml,我們將更詳細地分析它。
Header("內容類型:text/vnd.wap.wml");
printf("n");
printf("n");
printf("n");
// 下列各行是用來為要求授課時間建構SQL語句的
$consulting_tables = 🎜>"(professors left join teach on (professors.Id = teach.Id), subjects)";
$consulting_columns =
"professors.Surname, professors., $consulting_columns .=
"subjects.Cod_number, professors.Consulting_hour, professors.Consulting_place";
$c>"subjects.Cod_Subject = tod.Sub時間建構SQL語句的
$exams_tables= "(exams left join professors ON (exams.Id = professors.Id), subjects)";
$exams_columns= "subjects.S.Sconjectn. , ";
$exams_columns.= "professors.Name, exams.Date, exams.Time, exams.Room, exams.Test";
$exams_query= "exams。 >// 以下各行是用來為查詢測驗時間表的sql語句增加查詢限制
if ($exams_data) {
switch($exams_data) {
case "subject":
.= " and subjects.Subject like '%$subject%'";
break;
case "surname":
$exams_query.= " and professors.Surnamen dike'Surname%';
break;
}
}
// 下列各行是用來為查詢課程時間的sql語句增加查詢限制
if ($consulting_data) {問題{
case "subject":
$consulting_query
.= " and subjects.Subject like '%$subject%'";
break; consulting_query.= " and professors.Surname like '%$surname%'";
break;
}
}
// 處理與資料庫的連線
}
// 處理與資料庫的連接 data, $condition_passed) {
//
// put your password and username in next line
//
$db = my_pconnect("local *");
// put your database name in next line
mysql_select_db("lanfranchi_co_uk",$db);
$order = "SELECT $data FROMtables WHERE. ";
$result = mysql_query($sql,$db);
return $result;
}
//$res {
global $file;
printf("n");
printf(" <P>Receiving hours
n"); {
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"); " <P>$myrow[5]</P>n");
}
printf("</CARD>n");
}
/函數產生測驗的wml程式碼
function print_exams($exams_result) {
global $file;
printf("<CARD title='"hours"'>n"); hours
n");
while ($myrow = mysql_fetch_row($exams_result)) {
printf(" <P>$myrow[2], $myrow[2], $myrow[3]<P>$myrow[2], $myrow[2], $my." ;
printf(" <P>$myrow[0]</P>n");
printf(" <P>$myrow[1]]</P>n"); (" <P>$myrow[4], $myrow[5]</P>n");
printf(" <P>$myrow[7]</P>n"); (" <P>$myrow[6]</P>n");
}
printf("</CARD>n");
}]時間或測驗時間,連接資料庫且呼叫產生wml程式碼的函數
if ($consulting_data) {
$connection_result =
connect($consulting_tables, $consulting_colum
connect($consulting_tables, $consulting_colum
connect($consulting_tables, $consulting_colum
connect($consulting” connection_result);
}
if ($exams_data) {
$connection_result =
connect($exams_tables, $exams_cmh)$ ;
}
printf("</WML>n");
? >
好,完成了。你已經建立了首個基於MySQL資料庫的PHP/WML頁面了,自己繼續實踐一下吧。
以上就介紹了建立個人網站多少錢 建立動態的WML站點三,包括了建立個人網站多少錢方面的內容,希望對PHP教程有興趣的朋友有所幫助。