Files
BE_IBL/application/controllers/tools/Check_point_table.php
2026-04-15 15:23:57 +07:00

73 lines
1.7 KiB
PHP

<?php
class Check_point_table extends MY_Controller
{
function __construct()
{
parent::__construct();
}
function check()
{
$tables = [
"one_pointreward.member",
"one_pointreward.member_infonational",
"one_pointreward.member_national",
"one_pointreward.member_payment",
"one_pointreward.member_paymentdetail",
"one_pointreward.tx_whatsapp",
"one_pointreward.visit",
"one.f_memberdiscount",
"one.member_eligible",
"one.member_point_confirm",
"one.member_test_eksoteris",
"one.t_ordermemberdiscount"
];
$sql = "select ? as table_name, count(*) as records
from ? ";
$this->print_table_style();
foreach ($tables as $t) {
echo "<h5> Table : $t </h5>";
$qry = $this->db->query($sql, [$t, $t]);
if (!$qry) {
echo "<h5>Error : " . print_r($this->db->error(), true) . "</h5>";
continue;
}
$rows = $qry->result_array();
$this->print_table($rows, array_keys($rows[0]));
}
}
public function print_table_style()
{
echo "
<style>
th, td {
padding: 15px;
text-align: left;
}
tr:nth-child(even) {background-color: #f2f2f2;}
table {
border: solid 1px ;
min-width:600px;
}
</style>
";
}
public function print_table($rows, $keys)
{
echo "<table>";
echo "<tr>";
foreach ($keys as $k) {
echo "<td>$k</td>";
}
echo "</tr>\n";
foreach ($rows as $r) {
echo "<tr>";
foreach ($keys as $k) {
echo "<td>" . $r[$k] . "</td>";
}
echo "</tr>";
}
echo "</table>";
}
}