Values received after a question mark in the URL are split into arguments at the '+' character (normally used to represent the space character). You can still represent the space character using its hexadecimal representation - %20. (Note that this % character is not being used for formatting, it is part of the URL).
Form variables received via the POST method are decoded. Note that variables received by the GET method are not, so you must use the POST method for forms.
These arguments and variables can be substituted in the HTML, or in commands issued to the database. Further, the results of queries issued to the database can be formatted into HTML.
The formatting escapes provide a powerful mechanism for presenting the output of queries in any way desired, and for providing forms which can update the database.
Example:
Example:
Example:
For all column types, w specifies the minimum number of characters that should be used to display the column. If fewer characters are used, the column will be padded with spaces on the left for numeric columns, and on the right for other columns. It is only useful to specify a width in <PRE> and <XMP> sections.
For numeric column types, p specifies the number of decimal places to be displayed. For other columns, it specifies the maximum number of characters of data to be displayed. If no precision is supplied, a default is chosen based on information supplied by the DBMS.
You can omit the width and/or precision as follows:
This escape should only be used inside the sql format command.
Example: Output columns 2, then 3, then 1, with column 1 displayed to 2 decimal places.
This escape displays the column name for the specified column of the output record. It should only be used in the sql format or sql headings commands.
Example: display the column headings for column 2, then 3, then 1.
Arguments to a dbCGI script are received after a question mark ('?') in the URL used to access the script. dbCGI divides the string into arguments at '+' characters. These are normally used to represent the space character. Literal '+' and space characters can be supplied within an argument using their hexadecimal representation (%20 for space and %2B for '+').
Thus the following URL:
Example:
Text contained in this escape has all characters other than alphanumerics converted to their hexadecimal representation.
Example: Insert a hypertext link where we pass argument 1 through the link, and include column 3 as argument 2. Label the link with the text from column 5.
This escape should only be used in sql format commands. The text contained between %n( and %) is only included if the value in the specified column is not null.
Example: only include the heading 'Known Aliases' if field 5 is not null.
This escape should only be used in sql format commands. The enclosed text is only displayed if the value of one of the listed columns has changed since the previous record. This is used to generate a "report break" effect.
Example: columns 1, 2, and 3 are being used as headings, so they should only be displayed when they change, but we want column 2 to be displayed if column 1 is displayed, and column 3 to be displayed if column 2 has been displayed:
This escape should only be used in sql format commands. The specified column must be either binary (BLOB) data or character data. The contents of the column are stored in the named file. You can then put references to that file in your output HTML.
Example: Display the GIF image contained in the record, with the caption underneath.
Example: if your DBMS does not support BLOBs, but does support long text fields, store the data in uuencoded format, and have a script which converts the uuencoded data.
Example: Use argument 1 to condition the value of a character field:
This escape prevents this reformatting. The only time this escape is useful is in <PRE> and <XMP> sections.
Example: Output argument 1 in a <PRE> section.
%[-%1a%]
Example:
Example: Only include the WHERE clause if the ZIPCODE variable was received.
Example: if the ZIPCODE variable was not received, include the zip_code field in the query.
Example: The table "SEQUENCE" contains one record, with one field - seqno. This example increments the value of seqno, then places the new value in the form variable "SEQNO" for use in creating a unique ID in a later INSERT statement.