Difference between revisions of "Example datanavigation pysp"

From Lianjapedia
Jump to: navigation, search
(Created page with "== coming soon ==")
 
(coming soon)
Line 1: Line 1:
== coming soon ==
+
{{DISPLAYTITLE:Python Server Page Example}}
 +
 
 +
==Code==
 +
 
 +
<%@ Language=Python %>
 +
<!DOCTYPE html>
 +
<html>
 +
<head>
 +
<meta charset='utf-8'>
 +
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
 +
<link rel='stylesheet' href='../../library/bootstrap/css/bootstrap.min.css' type='text/css'/>
 +
<link rel='stylesheet' href='../../library/bootstrap-3.3.4/css/bootstrap.min.css'>
 +
<script src='../../library/jquery-1.10.2/jquery-1.10.2.min.js' type='text/javascript'></script>
 +
<script src='../../library/bootstrap-3.3.4/js/bootstrap.min.js' type='text/javascript'></script>
 +
<style>
 +
.tablecaption { background: gray; font-weight: bold; color: white; text-align:center; }
 +
</style>
 +
 
 +
</head>
 +
<body style="margin:10px;">
 +
<%
 +
import Lianja
 +
#
 +
# open the southwind database
 +
db = Lianja.openDatabase("southwind")   
 +
 
 +
# open a recordset
 +
rs = db.openRecordSet("select * from example")
 +
 
 +
# main table
 +
print("<table class='table'>")
 +
print("<caption class='tablecaption'> Example Python Report using bootstrap</caption>")
 +
 
 +
# column headings
 +
rs.movefirst()
 +
print("<tr bgcolor='lightgray' class='smallfont'>")
 +
for j in range( rs.fcount() ):
 +
print("<th><font color='white'>" + rs.fields(j).name + "</font></th>")
 +
print("</tr>")
 +
 
 +
# Traverse the recordset and write the output into the Webview section.
 +
for i in range( rs.reccount() ):
 +
if ((i%2) == 0):
 +
rowcolor = "#f1f6fe"
 +
altcolor = "#FFFFFF"
 +
else:
 +
rowcolor = "#FFFFFF"     
 +
altcolor = "#f1f6fe"
 +
print("<tr bgcolor='" + rowcolor + "' color='darkgray' class='smallfont' valign=top>")
 +
for j in range( rs.fcount() ):
 +
if rs.fields(j).name in [ "LIMIT", "BALANCE", "AVAILABLE" ]:
 +
print("<td align=right>$%.2f</td>" % rs.fields(j).value)
 +
else:
 +
print("<td>%s</td>" % rs.fields(j).value)
 +
print("</tr>")
 +
rs.movenext()
 +
 
 +
# end of table
 +
print("</table>")
 +
 
 +
# Close the RecordSet
 +
rs.close()
 +
 
 +
%>
 +
</body>
 +
</html>
 +
</code>

Revision as of 23:16, 7 April 2019


Code

<%@ Language=Python %> <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <link rel='stylesheet' href='../../library/bootstrap/css/bootstrap.min.css' type='text/css'/> <link rel='stylesheet' href='../../library/bootstrap-3.3.4/css/bootstrap.min.css'> <script src='../../library/jquery-1.10.2/jquery-1.10.2.min.js' type='text/javascript'></script> <script src='../../library/bootstrap-3.3.4/js/bootstrap.min.js' type='text/javascript'></script> <style> .tablecaption { background: gray; font-weight: bold; color: white; text-align:center; } </style>

</head> <body style="margin:10px;"> <% import Lianja

  1. open the southwind database

db = Lianja.openDatabase("southwind")

  1. open a recordset

rs = db.openRecordSet("select * from example")

  1. main table
print("") print("")
  1. column headings
rs.movefirst() print("") for j in range( rs.fcount() ): print("") print("")
  1. Traverse the recordset and write the output into the Webview section.
for i in range( rs.reccount() ): if ((i%2) == 0): rowcolor = "#f1f6fe" altcolor = "#FFFFFF" else: rowcolor = "#FFFFFF" altcolor = "#f1f6fe" print("") for j in range( rs.fcount() ): if rs.fields(j).name in [ "LIMIT", "BALANCE", "AVAILABLE" ]: print("" % rs.fields(j).value)

else:

print("" % rs.fields(j).value) print("") rs.movenext()
  1. end of table
print("
Example Python Report using bootstrap
" + rs.fields(j).name + "
$%.2f%s
")
  1. Close the RecordSet

rs.close()

%> </body> </html> </code>