CodeAve.com CodeAve.com - ASP - Database Table Display
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


Print View (From a db template)
Web pages usually print pretty lousy. Typically, background colors are not displayed (unless you change the browser settings) and depending on site the width may be set much wider than the printer can handle on the horizontal for an 8 ˝ page. Providing a printer friendly format adds immeasurable value for your users. There are two basic ways that a print view page can be generated. The first way is with a separate page that just has the “guts” of the page display without the banners and other items (this is how the Print View Icon on CodeAve.com works). The second is to strategically place a couple of simple tautologies that will display banners and other items in the typical or “default” view and allows a link back to the same page with a querystring value that will be used to suppress everything but the db output. The following is an example of the latter.
View the Output
Text View
Print View
Mail this Link
Download the Code
View the Data

<% view=request.querystring("view") %>
<html>
<body bgcolor="#FFFFFF">
<% if view <> "print" then 
' if the user has not selected the print view
' then display the top table, banner, and navigation area 
%>
<div align="center"><center>
<table border="0" width="100%">
<tr><td width="100%" bgcolor="#000000">
<p align="center">
<font color="#FFFFFF">Career Statistics for Mark Fidrych</font>
</td></tr>
</table>
</center></div>
<div align="center">
<center>
<table border="0" width="468">
<tr> <td width="468" height="60" bgcolor="#FFFFCC">
<p align="center">Banner Ad Goes Here
</td></tr>
</table>
</center>
</div>
<div align="center">
<center>
<table border="0" width="100%">
<tr><td width="15%" valign="top" align="left">
<a href="<%= request.servervariables("script_name") %>?view=print">Print View</a>
<br>
<table width = "125" height="125" bgcolor="#FFFFCC">
<tr><td>&nbsp;</td></tr></table> 
<p>&nbsp;</p>
</td>
<td width="85%">
<% end if 
' ending the tautology here allows for the stats
' to display in the print view by itself
' or integrated into a cell of the template %>
<% 
dim accessdb, cn, rs, sql
' Name of the Accessdb being read
accessdb="fidrych" 

' Connect to the db with a DSN-less connection
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")

' Select all data from the table the_bird
sql = "select * from the_bird " 

' Execute the sql
rs.Open sql, cn
%>

<table BORDER="1" CELLSPACING="0" align="center" width="640">
<caption>Mark "The Bird" Fidrych</caption>
<tr>
<td>Year</td>
<td>Team</td>
<td>W</td>
<td>L</td>
<td>G</td>
<td>GS</td>
<td>CG</td>
<td>IP</td>
<td>H</td>
<td>BB</td>
<td>SO</td>
<td>ShO</td>
<td>ERA</td>
</tr>
<%
' Move to the first record
rs.movefirst

' Start a loop that will end with the last record
do while not rs.eof
%>


<tr>
<td>
<%= rs("year") %>
</td>

<td>
<%= rs("team") %>
</td>

<td>
<%= rs("w") %>
</td>

<td>
<%= rs("l") %>
</td>

<td>
<%= rs("g") %>
</td>

<td>
<%= rs("gs") %>
</td>

<td>
<%= rs("cg") %>
</td>

<td>
<%= rs("ip") %>
</td>

<td>
<%= rs("h") %>
</td>

<td>
<%= rs("bb") %>
</td>

<td>
<%= rs("so") %>
</td>

<td>
<%= rs("sho") %>
</td>

<td>
<%= rs("era") %>
</td>
</tr>

<%
' Move to the next record
rs.movenext
' Loop back to the do statement
loop %>

</table>

<% if view <> "print" then 
' if the user has not selected the print view
' then display the footer info %>

</td></tr>
</table>
</center></div>
<p>&nbsp;</p>
<div align="center"><center>
<table border="0" width="100%">
<tr><td width="100%">
<p align="center">Copyright and Footer Info Go Here
</td></tr></table></center></div>
<% end if %>
</body></html>

<%
' Close and set the recordset to nothing
rs.close
set rs=nothing
%>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
Maps: Map Script Writers | Bing Maps | Google Maps
Privacy Statement

CodeAve.com is hosted by MyHosting.com
Donate Food Online with a Mouse Click at TheHungerSite.com
Donate Land Online with a Mouse Click at TheRainForestSite.com
© 1999 - 2014 CodeAve.com
All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3