dbCGI |
if directive |
|||||||||||||||||||||
|
Back To: Directives, Flow control directives Directive Nameif Directive TypeSynopsis<sql if> ... </sql> DescriptionThe if directive process its contents conditionally. The contents will include one or more conditions (introduced with <sql-if ...>) and an optional "else" marker (<sql-else/>). Each condition tests to see if some condition is true. The if directive will process any contents from the first condition that is true, through to the next condition or "else" marker. If no conditions are true, the if directive will process any contents from the "else" marker through to the end of the if directive. The following conditions are recognised:
Examples<sql if> <sql-if evaluate> %r > 20 </sql-if> <p>More than 20 rows were returned</p> <sql-if anyrows/> <p>Some rows returned</p> <sql-else/> <p>No rows returned</p> </sql> <sql format/> <sql error/> <sql query c1> select name from passwords where user = %[+user%] and pass = %[+pass%] </sql> <sql if> <sql-if haderror/> <h1>Error accessing user database</h1> <p> There was an error accessing the user database. Please try again later. </p> </body> </html> <sql exit/> <sql-if norows/> <h1>Authentication failed</h1> <p> Your user name or password was incorrect. </p> </body> </html> <sql exit/> </sql> |