Example #1
0
 function html_results($cur, $fmt = 1, $link_col = 0, $link = '', $show_no_rows = 1)
 {
     if ($fmt) {
         u::p('<style>table td {white-space: nowrap;border: 1px solid silver;font-family:Courier New}</style>');
         u::p('<table>');
     } else {
         u::p('<pre>');
     }
     $print_header = 1;
     $rows_fetched = 0;
     while ($rec = oci_fetch_object($cur)) {
         $rows_fetched++;
         if ($fmt) {
             u::p('<tr>');
         }
         #
         # Display column headers
         #
         if ($print_header) {
             if ($fmt) {
                 u::p('<tr>');
             }
             foreach ($rec as $key => $val) {
                 if ($fmt) {
                     u::th($key, 'style="background-color:silver;color:white"');
                 } else {
                     u::p($key);
                 }
             }
             if ($fmt) {
                 u::p('</tr>');
             }
             $print_header = 0;
         }
         #
         # Row data
         #
         if ($fmt) {
             u::p('<tr>');
         }
         $col = 0;
         foreach ($rec as $key => $val) {
             $col++;
             if ($col === $link_col) {
                 $val = u::a($val, str_replace('__VAL__', $val, $link), 1);
             }
             if ($fmt) {
                 #
                 # Extra formatting?
                 #
                 if ($val == 'CRITICAL') {
                     $extra = 'style="background-color:red;"';
                 } else {
                     $extra = '';
                 }
                 u::td($val, $extra);
             } else {
                 u::p($val);
             }
         }
         if ($fmt) {
             u::p('</tr>');
         }
     }
     oci_free_statement($cur);
     if (!$rows_fetched and $fmt and $show_no_rows) {
         u::trtd('No Rows Returned', 'style="background-color:red;"');
     }
     if ($fmt) {
         u::p('</table>');
     } else {
         u::p('</pre>');
     }
 }