_Publishing Dynamic Data on the Internet_
by Lauren Hightower

Listing One
<DBOUTPUT Query="ListProducts" Group="ProductType">
<center><HR></center>
<H2>#ListProducts.ProductType#</H2>
<DBOUTPUT>
<FORM ACTION="http://www.calico-company.com/cgi-shl/dbml.exe?
 Template=hnsorder.dbm" METHOD=Post>
<input type=hidden name=shopid value=#shopid#>
<input type=hidden name=prodid value=#productid#>
<input type=hidden name=quantity_required value="You must enter a quantity.">
<input type=hidden name=quantity_number value="The quantity must be a number.">
<center><HR width=500></center>
<P><STRONG><Font Size=+1>#ProductName#</font></STRONG> 
 <dbif #MfgID# is not "">(#MfgID#)</dbif>
<br><STRONG>Price:</STRONG> #DollarFormat(PriceEach)# each (#PerCase# per case)
<br>Quantity: <input type=text name=quantity value="1" size=3> 
(this must be a number)
<p><input type=submit value=" Order Now ">
</form>
<EM>#ProductDescription#</EM>
</DBOUTPUT>
</DBOUTPUT>


Listing Two
<input type=hidden name=quantity_required value="You must enter a quantity.">
<input type=hidden name=quantity_number value="The quantity must be a number.">


Listing Three
<DBQUERY Name="InsertItem" DataSource="Calico" SQL="INSERT INTO hns_orderdetail
(Shoppingid, ProductID, ProductQuantity) VALUES(#form.shopid#,
#form.prodid#,#form.quantity#)">
<DBQUERY NAME="FindOrders" DataSource="Calico" SQL="SELECT 
hns_products.ProductName, hns_orderdetail.ProductQuantity, 
hns_products.MfgID FROM (hns_orderdetail INNER JOIN 
hns_orders ON hns_orderdetail.ShoppingID = 
hns_orders.shoppingId) INNER JOIN hns_produ
cts ON hns_orderdetail.ProductID = hns_products.ProductID WHERE 
(((hns_orderdetail.ShoppingID)=#form.shopid#))">
<DBQuery NAME="TotalOrder" DataSource="Calico" SQL="SELECT 
Sum(hns_products.PriceEach) AS TotalCost FROM 
(hns_orderdetail INNER JOIN hns_orders ON 
hns_orderdetail.ShoppingID = hns_orders.shoppingId) 
INNER JOIN hns_products ON hns_orderdetail.ProductID = hn
s_products.ProductID WHERE hns_orderdetail.ShoppingID=#form.shopid#">
<DBQuery NAME="TotalCost" DataSource="Calico"
SQL="SELECT Sum([ProductQuantity]*[PriceEach]) AS RealCost FROM 
(hns_orderdetail INNER JOIN hns_orders ON 
hns_orderdetail.ShoppingID = hns_orders.shoppingId) 
INNER JOIN hns_products ON hns_orderdetail.ProductID = 
hns_products.ProductID WHERE hns_orderdetai
l.shoppingid=#shopid#">
<DBOUTPUT QUERY="FindOrders">
<li><strong>#ProductQuantity# #ProductName#</strong> 
 <dbif #MfgID# is not "">(#MfgID#)</dbif>
</DBOUTPUT>
</ul>
<DBOUTPUT QUERY="TotalCost">
<p><strong>TOTAL : </strong>#DollarFormat(RealCost)#
</DBOUTPUT>


Listing Four
<DBIF #RealCost# less than 15>
<P><strong>The minimum order we can mail is $15.00. You have not reached that amount yet.
<P>To continue shopping, press the BACK button on your browser to get back to the product listing you were viewing.</strong>
</dbelse>
<P>To finalize your order and submit your order form with the items listed, fill out the information below.</strong>
</dbif>


Listing Five
<DBMAIL QUERY="FindOrders"
 FROM="calico@supernet.net"

 TO="calico@supernet.net"
 SUBJECT="Hot N Stuf Order Form">


Listing Six
<DBQUERY NAME="FindEmail" DataSource="calico" SQL="SELECT email 
 FROM recipients">
<DBMAIL QUERY="FindEmail"
 FROM="calico@supernet.net"
 TO="#email#"
 SUBJECT="Hot N Stuf Order Form">
 Here is the information for a new order placed through the Online Catalog.
</DBMAIL>


