|
CodeAve.com - ASP - Database Table Display | ||||
|
|
||||
| Print View (From a db template) | |||||
|
|
|||||
<% 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> </td></tr></table> <p> </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> </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 %>
|
|||||
|
|
|||||