本文整理汇总了PHP中SafeMySQL::getCol方法的典型用法代码示例。如果您正苦于以下问题:PHP SafeMySQL::getCol方法的具体用法?PHP SafeMySQL::getCol怎么用?PHP SafeMySQL::getCol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeMySQL
的用法示例。
在下文中一共展示了SafeMySQL::getCol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SafeMySQL
<?php
require_once "pass.php";
require_once "lib/safemysql.class.php";
$tableName = "tickets";
echo "Log in MySQL<br>\n";
$db = new SafeMySQL(['host' => $loginData['mysql_host'], 'user' => $loginData['mysql_username'], 'pass' => $loginData['mysql_password'], 'db' => $loginData['mysql_db']]);
echo "<br>List fields in table:<br>\n";
$sql = "SHOW COLUMNS FROM {$tableName}";
$fields = $db->getCol($sql);
//Print table to HTML
?>
<table border="1">
<thead>
<tr>
<?
foreach($fields as $fieldname) {
echo "<td>$fieldname</td>\n";
}
echo "</tr></thead><tbody>";
$data=$db->getAll("SELECT * FROM $tableName ORDER BY dtime DESC LIMIT 100");
foreach($data as $row=>$cols) {
echo"<tr>";
foreach($cols as $col) {
echo " <td>$col</td>\n";
}
echo "</tr>\n";
}
echo "</tbody></table>";
?>