ASP technology in WAP (4)
Author:Eve Cole
Update Time:2009-05-30 19:54:43
Choose a theater and show time
This part of the code allows the user to choose what time to watch the movie. All records are determined based on the movie selected on the previous page. Choose your theater and show time here.
movie_id = Request("movie")
sqlQuery = "SELECT title FROM movie WHERE Movie_id = " & movie_id
set rsMovie = conn.Execute(sqlQuery)
movie_title = rsMovie("title")
:
sqlQuery = "SELECT [name], [time], [show_id] FROM Show, Theater " &_
"WHERE show.movie_id = " & movie_id &_
"AND theater.theater_id = show.theater_id"
set rsShows = conn.Execute(SQLquery)
If you study this code carefully, you will want to use Session to save movie information, and then query it on this page is easier. Also unfortunately, Session is required
Although cookie support is also supported in the WAP specification, it is not supported in Nokia 7110. This means that we cannot use session in WAP yet.
In service.
Here are some interesting things:
<select name='show'>
<%
Do while not rsShows.eof
response.write("<option value='" & rsShows("show_id") & "'>" & Left(rsShows("name"),cutter) & " (" &
rsShows("time") & ")" & "</option>" &vbcrlf)
rsShows.MoveNext
loop %>
</select>
If you're wondering about the cutter variable, here's something that will make you laugh or cry.
Dim cutter
if InStr(Request.ServerVariables("HTTP_USER_AGENT"), "Nokia7110") then
cutter = 12
else
cutter = 7
end if
This code displays options based on different devices. We have good reason to do this, the Nokia Toolit 1.2 emulator likes to cut my options down to just a few characters, and we want to display the movie name and release date, so we have to reduce the characters of the movie name. This problem does not occur in real mobile phones, so we must first determine the type of device.
Once I had the chance (I was poor and had no money, this was just a distant dream...) to test my code on a real Nokia 7110, we immediately felt that we had more than we thought. Big screen. In fact, some movie theaters have weird names, and these long names will take up a lot of screen space. There is no need to waste this display space and try to simplify these names.
ticket
The next step is to let the user select the desired number of votes. This part of the code is much like the other parts. I will query the same data from the database because Session cannot be used in real
WAP phone is used, so I have to check some content to see if there are still seats for sale.
SQLquery = "SELECT * FROM show WHERE Show_id = " & show_id
set rsShow = conn.Execute(SQLquery)
:
seats = rsShow("free_seats")
:
if seats = 0 then
Response.write("Sorry, no more seats")
rsShow.close
set rsShow = nothing
Response.write("</p></card></wml>")
Response.end
else
if seats > 6 then 'book up to 6 tickets or max available
max_seats=6
else
max_seats = seats
end if
end if
%>
<%=movie_title%> at <% =theater_name%>
<select name='ticket'>
<%
dimi
i=1
Do while i <= max_seats
response.write("<option value='" & i & "'>" & i & " ticket(s)" & "</option>" &vbcrlf)
i = i + 1
loop %>
</select>
Save votes
Now that we have all the data we need, we need to save it:
tickets = Request("ticket")
:
free_seats = rsShow("free_seats")
:
free_seats = free_seats - tickets
:
SQLUpdate = "UPDATE Show " &_
"SET Show.free_seats=" & free_seats & " " &_
" WHERE Show_ID=" & show_id
conn.Execute(SQLupdate)
SQLquery = "SELECT max([Booking_ID]) as bookingnumber FROM booking"
Set rsBooking = conn.execute(SQLquery)
maxbookid = rsBooking("bookingnumber") + 1
SQLinsert = "INSERT INTO Booking ( show_id, booked_seats ) " & _
"VALUES ('" & show_id & "', '" & tickets & "')"
conn.Execute(SQLinsert) %>
You have booked <%=tickets%> ticket(s) for <%=movie_title%><br />
The show will take place at <%=theater_name%> (<%=time%>)
<br />
Your reference number is <%=maxbookid%>
Below is the display:
Figure 4: Complete transaction.
The transaction has been completed, and the cinema can sit at the door of the cinema to collect money.
in conclusion
WAP has only just taken its first steps, but it is one of the most revolutionary IT developments in recent years. In this article I introduce how to write WAP applications using asp,
And I have given you some warnings, which I hope will be useful for your future development. Multimedia technology still cannot be used too much in WAP, but its mobility is important and provides many business opportunities for merchants.