//display an T-SQL Query in textarea (for sql code debugging by example)
function ShowSQLQuery($q, $cols=100, $rows=10)
{
$dataSQL=ltrim($q);
$keySQL=array("select", "from", "where", "left", "inner", "case", "else", "when", "union", "union all","order", "group", " \) as");
foreach($keySQL as $key=>$value)
{
$dataSQL=eregi_replace(" ".$value, chr(13).chr(10).strtoupper($value), $dataSQL);
}
echo '<div style="text-align: center; width: 100%;"><textarea cols="'.$cols.'" rows="'.$rows.'" name="sql_query" id="sql_query">';
echo $dataSQL;
echo '</textarea></div>';
}