Advertisement
gridcube

Untitled

Sep 16th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1.  
  2.   $table = "<table align='center' border='1' cellpadding='2' cellspacing='2'>";
  3.   $cols = implode (', ', $fields);
  4.   $sql = "select $cols from $table_name";  
  5.   $run = mysql_query($sql);    
  6.      
  7.       if($run){    
  8.           if(mysql_num_rows($run) == 0){
  9.                   return "Sorry. No records found in the database";                        
  10.           }
  11.           else {
  12.                  
  13.               while($arr = mysql_fetch_array($run, MYSQL_ASSOC)){
  14.                       $table .= "\t\t<tr>\n";
  15.                      
  16.                       foreach ($arr as $val_col) {
  17.                         $newtext = wordwrap($val_col, 30, "<br />\n", true);
  18.                         if ($newtext == FAIL) {
  19.                             $newtext2 = "<span style='color: rgb(255, 0, 0);'>FAIL</span>";
  20.                         }
  21.                         elseif ($newtext == PASS) {
  22.                             $newtext2 = "<span style='color: rgb(0, 255, 0);'>PASS</span>";
  23.                         }
  24.                         else {
  25.                             $newtext2 = $newtext
  26.                       $table .= "\t\t\t".'<td>'.$newtext2.'</td>'."\n";
  27.                       } }
  28.                          
  29.                       $table .= "\t\t</tr>\n";                                        
  30.               }
  31.               $table .= "</table>";
  32.               return $table;
  33.            }
  34.          
  35.           mysql_free_result($run);        
  36.     }
  37.    
  38.   echo  mysql_error();
  39.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement