getMessage(); } //--------------------- // ShowTable //--------------------- function ShowTable($tablename, $where="", $orderby="") { $tables = $tablename; if($where != "") $where = "WHERE $where"; if($orderby != "") $orderby = "ORDER BY $orderby"; // First, check at least 1 row will be returned since we can do nothing // without at least one row. It seems like we should be able to get // this from the actual query below, but web documentation says this // is the proper and portable way. global $db; $query = "SELECT count(*) FROM $tables $where"; if($res = $db->query($query)){ if ($res->fetchColumn() == 0) { print "

No Entries

"; return; } }else{ print "

No table named \"$tablename\"

"; return; } // query the table $query = "SELECT * FROM $tables $where $orderby"; $res = $db->query($query); // Get column names $row = $res->fetch(PDO::FETCH_ASSOC); $cols = array_keys($row); // Make table with column names as headers $str = "\n"; $str .= "\n"; $str .= "\n"; foreach($cols as $col){ $str .= "\n"; } $str .= "\n"; // Enter first row of data $str .= "\n"; $vals = array_values($row); foreach($row as $col => $val){ if(strstr($col, "run") !== false){ $val = "$val"; } $bgcolor = "#F0F0F0"; if(strstr($col,"_time") != FALSE) $val = strftime("%c", $val); $str .= "\n"; } $str .= "\n"; // Enter remaining rows while($row = $res->fetch(PDO::FETCH_ASSOC)){ $str .= "\n"; foreach($row as $col => $val){ if(strstr($col, "run") !== false){ $val = "$val"; } $bgcolor = "#F0F0F0"; if(strstr($col,"_time") != FALSE) $val = strftime("%c", $val); $str .= "\n"; } $str .= "\n"; } // return results return $str; } ?>
$tablename
$col
$val
$val