Library tutorials & articles
Wireless Markup Language (WML) Tutorial
- Introduction
- Getting Started
- Working with Cards
- The Timer Element
- Images
- Tables
- Defining Tasks
- Getting User Input
- Meta Tags
- Creating Dynamic Content
Creating Dynamic Content
You can create dynamic WML documents with any server side language such as ASP, PHP, PERL, etc. The only thing you need to do is ensure the content type has been set for WML.
In ASP, you set the content type through the Response object.
Setting the content type with ASP
Response.ContentType = "text/vnd.wap.wml"
In PHP, you set the content type through the header function.
Setting the content type with PHP
<?php
header("Content-type: text/vnd.wap.wml");
?>
A Search Page
The following describes how to create a search page for a WAP device. The first thing we need to consider is how we'll be sending data from the WML document to the server. By default, the input element uses the GET HTTP submission method. This isn't an issue with PHP, but with ASP it will mean the data will need to be retrieved through the Request object's QueryString collection. This isn't a problem, but to illustrate the difference, the following example uses the POST method to send the data. The data will need to be retrieved through the Request object's Form collection with ASP when data is submitted using this method.
search.wml
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="index" title="Search Term">
<do type="accept" label="Search Term">
<go href="terms.asp" method="post">
<postfield name="term" value="$term"/>
</go>
</do>
<p>
Enter a search term:
<input type="text" name="term" value=""/>
</p>
</card>
</wml>
The following is an ASP document to perform the search, and return a WML document.
terms.asp
<%@ language="vbscript" %>
<% Option Explicit %>
<% Response.ContentType = "text/vnd.wap.wml" %>
<!-- #include file="adovbs.inc" -->
<%
Dim objDB, objRS, strConnect, strDBVirtualPath, strDBLocation, strSQL
Dim strTerm, strDescription, counter
strDBVirtualPath="db/terms.mdb"
strDBLocation=Server.Mappath(strDBVirtualPath)
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBLocation
Set objDB = Server.CreateObject("ADODB.Connection")
objDB.Open strConnect
Set objRS = Server.CreateObject("ADODB.RecordSet")
' Get the search term. This would be Request.QueryString("term") if
' no method had been specified for the input element
strTerm = Request.Form("term")
strSQL = "SELECT * FROM Terms WHERE [Term] LIKE '%" & strTerm & "%'"
objRS.Open strSQL, objDB, adOpenStatic, adLockReadOnly, adCmdText
%>
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="term" title="Terms">
<do type="prev" label="Back">
<prev/>
</do>
<p>
<%
If objRS.EOF Then
' No terms found in the recordset
Response.Write "Unable to retrieve any records like " & strTerm
Else
Response.Write "Terms with <em>" & strTerm & "</em><br/>"
' Get each term that matches
Do While NOT objRS.EOF
counter = counter + 1
Response.Write "<em>" & objRS.Fields("Term").Value & "</em><br/>"
strDescription = Server.HTMLEncode(objRS.Fields("Description").Value)
Response.Write strDescription & "<br/>"
Response.Write "---<br/>"
objRS.MoveNext
Loop
Response.Write "Retrieved " & counter & " term(s) containing " & strTerm
End If
' Tidy up
objRS.Close
Set objRS = Nothing
objDB.Close
Set objDB = Nothing
%>
</p>
</card>
</wml>
You can see this script in action at: http://www.juicystudio.com/search.wml
Related articles
Related discussion
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
ideas in building a captive portal
by sjranjan (2 replies)
-
A particular gallery image
by margy80 (0 replies)
-
(Very urgent)how to assign the value of the variable in javascript function into php variable
by mazhar_qayyum (3 replies)
-
Iterating through DB rows by column name
by fil.moore (0 replies)
Related podcasts
-
EarthClassMail.com - Moving from LAMP to .NET 3.5
Scott chats with Matt Davis, architect at EarthClassMail.com, about their move from a LAMP stack (Linux/Apache/mysql/PHP) to .NET 3.5. What's working, what's not, and what kinds of issues are they running into as their architect their solution.
Events coming up
-
Dec
3
The Auckland PHP December meetup
Auckland, New Zealand
Topic: Magento E-Commerce platform Speaker: Robert Popovic, LERO9, Robert is the Technical Director and co-founder of LERO9. Robert attended the Electrotechnical Faculty at The University of Belgrade where he graduated with a Masters in Computer Science and Information Technology. Robert has worked exclusively in the field of web and software development throughout his career.
hi
I am Jagannath working as Sr.Programmer in Med Write India Ltd. I have one doubt that how to search the latest modified file on the stipulated time and date.If you will help me then i will be happy
Bye
Jagannath
my alternate email address is b_jagan03@yahoo.co.in
Phno : 09849654314
Nice articlae but require more info on this
This thread is for discussions of Wireless Markup Language (WML) Tutorial.