GSAK (Geocaching Swiss Army Knife)
 

Contents - Index


SqlToHtml (function)

SqlToHtml(sSqlData, sHeading, sOptions) : string

This function provides a quick and easy way to view sql data.

sSqlData - The resulting string of a GSAK SQL Query
sHeading - The heading for the HTML generated table
sOptions - Comma delimited options. Currently only one being Y= display result in browser

The return result is the generated html code. You would normally include the Y option to display the HTML so the result can usually be ignored, but is provided so you can save to a file or further manipulate.

Note: You can run more than one sql command at a time and a function parameter may include a function, therefore the following report can actually be generated in just 2 lines of code (generate the data, run sqltohtml). However for clarity I have broken it down line by line.
 

# First create the required sql file
$result = DbToSQLite("logs","lparent,ltype,llogid",":memory:")

# get the sql data to display
$result = sqlite("sql","Select ltype as LogType, count(ltype) as Total  from logs  GROUP by logtype ORDER by logtype","Headings=Yes")

# display the data
$html = sqltohtml($result,"Summary by log type","y")

 
This should open up a report in your browser that looks something like:



This generated report allows you to sort any column by clicking on the column heading

Summary
Copyright 2004-2008 CWE Computer Services  
Privacy Policy Contact