MySQL::GetHTML PHP Method

GetHTML() public method

This function returns the last query as an HTML table
public GetHTML ( boolean $showCount = true, string $styleTable = null, string $styleHeader = null, string $styleData = null ) : string
$showCount boolean (Optional) TRUE if you want to show the row count, FALSE if you do not want to show the count
$styleTable string (Optional) Style information for the table
$styleHeader string (Optional) Style information for the header row
$styleData string (Optional) Style information for the cells
return string HTML containing a table with all records listed
    public function GetHTML($showCount = true, $styleTable = null, $styleHeader = null, $styleData = null)
    {
        if ($styleTable === null) {
            $tb = "border-collapse:collapse;empty-cells:show";
        } else {
            $tb = $styleTable;
        }
        if ($styleHeader === null) {
            $th = "border-width:1px;border-style:solid;background-color:navy;color:white";
        } else {
            $th = $styleHeader;
        }
        if ($styleData === null) {
            $td = "border-width:1px;border-style:solid";
        } else {
            $td = $styleData;
        }
        if ($this->last_result) {
            if ($this->RowCount() > 0) {
                $html = "";
                if ($showCount) {
                    $html = "Record Count: " . $this->RowCount() . "<br />\n";
                }
                $html .= "<table style=\"{$tb}\" cellpadding=\"2\" cellspacing=\"2\">\n";
                $this->MoveFirst();
                $header = false;
                while ($member = mysqli_fetch_object($this->last_result)) {
                    if (!$header) {
                        $html .= "\t<tr>\n";
                        foreach ($member as $key => $value) {
                            $html .= "\t\t<td style=\"{$th}\"><strong>" . htmlspecialchars($key) . "</strong></td>\n";
                        }
                        $html .= "\t</tr>\n";
                        $header = true;
                    }
                    $html .= "\t<tr>\n";
                    foreach ($member as $key => $value) {
                        $html .= "\t\t<td style=\"{$td}\">" . htmlspecialchars($value) . "</td>\n";
                    }
                    $html .= "\t</tr>\n";
                }
                $this->MoveFirst();
                $html .= "</table>";
            } else {
                $html = "No records were returned.";
            }
        } else {
            $this->active_row = -1;
            $html = false;
        }
        return $html;
    }

Usage Example

Example #1
0
        }
    }
    //finish suppcode check
    $sql = "SELECT prodgroup FROM hkmatrix WHERE uid = " . $i;
    $results = $db->QuerySingleRowArray($sql);
    $pgcode = $results[0];
    if ($pgcode) {
        $sql2 = "SELECT hkcategory, wwwcategory FROM categories WHERE code = '" . $pgcode . "'";
        //print $sql2."<br>";
        $subresults = $db->Query($sql2);
        if (!empty($subresults)) {
            $ns = $db->fetchRow($subresults);
            //print_r($ns);
            if ($ns[1]) {
                $newsupp = $db->clean($ns[1]);
            } else {
                $newsupp = $db->clean($ns[0]);
            }
            $sql3 = "UPDATE hkmatrix SET prodgroup ='" . $newsupp . "' WHERE uid = " . $i;
            //print "<br> $sql3";
            $results = $db->Query($sql3);
        }
    }
    // end pgcode check
}
if ($cli == 0) {
    $sql = "SELECT * FROM hkmatrix";
    $newresults = $db->Query($sql);
    print $db->GetHTML(false, 'width:100%;', 'font-size:10px;color:#000;background:#cc0;', 'font-size:9px;color:#000;border-width:1px;border-style:solid;');
    echo '<br>All imported. It is safe to close this tab and continue with import.<input type="button" value="Close" onclick="window.close()" /><br>';
}
All Usage Examples Of MySQL::GetHTML