Exemple #1
0
 function displayGrid($tablename, $begin)
 {
     parent::openConnection();
     if ($begin < strval($this->start) + strval($this->perPage)) {
         $this->start = 0;
         $this->end = strval($this->start) + strval($this->perPage);
     } else {
         $this->start = $begin;
         $this->end = strval($this->start) + strval($this->perPage);
     }
     $this->sql = "SELECT * FROM `{$tablename}` Limit {$this->start},{$this->perPage}";
     $this->rowOut = parent::query2DArray($this->sql);
     $this->nr_rows = parent::queryNumRows();
     $this->nr_cols = parent::queryNumCols();
     echo "<center><table border=1 width={$this->tableWidth} bordercolor={$this->borderColor} cellpadding={$this->cellPadding} cellspacing={$this->cellSpacing}>\n";
     // Get Column Headers ---------------
     if ($this->showHeader == 1 && $this->customHeader == "") {
         $this->sql = "SHOW COLUMNS FROM `{$tablename}`";
         $this->colOut = parent::query2DArray($this->sql);
         $this->nr_rows2 = count($this->colOut);
         echo "<tr>";
         for ($i = 0; $i < $this->nr_rows2; $i++) {
             echo "<td><center><b>" . $this->colOut[$i][0] . "</b></center></td>";
         }
         echo "</tr>\n";
     } elseif ($this->showHeader == 1 && $this->customHeader != "") {
         $cHeader = explode("|", $this->customHeader);
         $this->nr_rows2 = count($cHeader);
         echo "<tr>";
         for ($i = 0; $i < $this->nr_rows2; $i++) {
             echo "<td><center><b>" . $cHeader[$i] . "</b></center></td>";
         }
         echo "</tr>\n";
     }
     // Show Detail ----------------------
     for ($i = 0; $i < $this->nr_rows; $i++) {
         echo "<tr>";
         for ($j = 0; $j < $this->nr_cols; $j++) {
             echo "<td>&nbsp;" . $this->rowOut[$i][$j] . "</td>\n";
         }
         echo "</tr>\n";
     }
     echo "<br><br><tr><td colspan={$this->nr_cols}><center>\n";
     if ($this->start > 0) {
         echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?st=" . ($this->start - $this->perPage) . "\"><b>&lt;&lt</b></a>";
     }
     echo " <b> | </b> <a href=\"" . $_SERVER['PHP_SELF'] . "?st=" . (strval($this->start) + strval($this->perPage)) . "\"><b>&gt;&gt</b></a>";
     echo "</center></tr>\n";
     echo "</table></center>\n<br><br>\n";
     parent::closeConnection();
 }
Exemple #2
0
<?php

///////////////////////////////////
// Example to Show How to get 2D
// Array AKA Recordset from a
// Database and output to screen
///////////////////////////////////
include "dbclass.php";
$a = new dbClass('localhost', 'test', 'root', 'password');
$rowOut = array();
$tblList = array();
$dbList = array();
// Set connection variables and open database connection ------------------------------------
$a->openConnection();
// Execute Single Row Query and display results ---------------------------------------------
$sql = "SELECT * FROM `test1`";
$rowOut = $a->query2DArray($sql);
$nr_rows = $a->queryNumRows();
// Number of rows in dataset
$nr_cols = $a->queryNumCols();
// Number of columns in dataset
echo "<table border=1 bordercolor=black>";
for ($i = 0; $i < $nr_rows; $i++) {
    echo "<tr>";
    for ($j = 0; $j < $nr_cols; $j++) {
        echo "<td>" . $rowOut[$i][$j] . "</td>";
    }
    echo "</tr>";
}
echo "</table><br><br>";
echo "<b>Number of Columns in Query is:</b> " . $nr_cols . "<br>";
Exemple #3
0
    //echo "<br>".$difference."<br>";
    return $difference;
}
include "whoisonline_config.php";
include "dbclass.php";
$count = 0;
if ($_SESSION['entrytime'] == "") {
    $_SESSION['entrytime'] = time();
}
if (file_exists("install.php")) {
    echo "Who Is Online Security:<br>Please Remve <b>install.php</b>.";
    exit;
}
$db1 = new dbClass();
$db1->setDBVars($dbhost, $dbname, $dbuser, $dbpass);
$db1->openConnection();
$ip = $_SERVER['REMOTE_ADDR'];
$sql = "SELECT COUNT(*) FROM `{$dbname}`.`{$dbtable}` WHERE `ip`='{$ip}';";
$rowOut = $db1->queryRowArray($sql);
$ip_exists = $rowOut[0];
if ($ip_exists > 0) {
    $sql = "SELECT COUNT(*) FROM `{$dbname}`.`{$dbtable}`";
    $rowOut = $db1->queryRowArray($sql);
    $count = $rowOut[0];
} else {
    $db1->execCommand("INSERT INTO `{$dbname}`.`{$dbtable}` (`ip`) VALUES ('{$ip}');");
    $sql = "SELECT COUNT(*) FROM `{$dbname}`.`{$dbtable}`;";
    $rowOut = $db1->queryRowArray($sql);
    $count = $rowOut[0];
}
echo "<table>";
Exemple #4
0
<?php

/////////////////////////////////////
// Example to show how to obtain
// a resultset from a database table
/////////////////////////////////////
include "dbclass.php";
// Set connection variables and open database connection ------------------------------------
$db = new dbClass('localhost', 'database', 'root', 'password');
$db->openConnection();
// Execute Single Row Query and display results ---------------------------------------------
$sql = "SELECT * FROM `test1`;";
$result = $db->queryResultset($sql);
$i = 0;
$num = mysql_numrows($result);
while ($i < $num) {
    $c1 = mysql_result($result, $i, "column1");
    $c2 = mysql_result($result, $i, "column2");
    echo "{$c1} - {$c2} <br>";
    $i++;
}
$db->closeConnection();