5.4. Presenting Query Results via a Web Page
Armed with new knowledge of how to fetch data from the database into PL/SQL, we can now contemplate presenting the data on a web page. How `bout we start by implementing a simple-minded web page that will dump all the data in the table? Well, it seems easy enough on the surface:
<%@ page language="PL/SQL" %>
<%@ plsql procedure="q" %>
<HTML>
<HEAD>
<TITLE>Search</TITLE>
</HEAD>
<BODY bgcolor="white">
<%
FOR bk IN (SELECT * FROM books)
LOOP
%>
<%= bk.isbn %>
<%= bk.title %>
<%= bk.author %>
<%= bk.date_published %>
<%= bk.page_count %>
<%= bk.summary %>
<BR>
<%
END LOOP;
%>
</BODY>
</HTML>
But when you actually view this page (see Figure 5-3), you're in for a rude awakening, because it's so badly arranged that it's virtually unusable.
Figure 5-3. Output from naïve "table-dumping" approach

This is a reminder that browsers have no respect for the spaces and line breaks that may appear in your HTML. What we need is a healthy dose of "nice and neat." Fortunately, there is a simple fix that will take us a long way toward making the web page pretty. The solution involves the HTML TABLE element, which I didn't get a chance to cover in the introduction to HTML in Chapter 3.
5.4.1. Introduction to HTML Tables
An HTML table is a structure on a web page that usually renders as a grid of nice, neat rows and columns. The simplest HTML table ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access