/* dblib.php (c) 2000 Ying Zhang (ying@zippydesign.com) * */ if (!isset($DB_DIE_ON_FAIL)) { $DB_DIE_ON_FAIL = true; } if (!isset($DB_DEBUG)) { $DB_DEBUG = false; } function db_connect($dbhost, $dbname, $dbuser, $dbpass) { global $DB_DIE_ON_FAIL, $DB_DEBUG; if (! $dbh = mysql_connect($dbhost, $dbuser, $dbpass)) { if ($DB_DEBUG) { echo "
mysql Error: ", mysql_error(); } else { echo "
This script cannot continue, terminating."; die(); } } if (! mysql_select_db($dbname)) { if ($DB_DEBUG) { echo "
mysql Error: ", "Greska"; } else { echo "
This script cannot continue, terminating."; die(); } } mysql_query("SET NAMES utf8"); mysql_query("SET CHARACTER utf8"); mysql_query("SET COLLATION_CONNECTION='utf8'"); return $dbh; } function db_disconnect() { mysql_close(); } function db_query($query, $debug=false, $die_on_debug=true, $silent=false) { global $DB_DIE_ON_FAIL, $DB_DEBUG; if ($debug) { echo "
" . htmlspecialchars($query) . ""; if ($die_on_debug) die; } $qid = mysql_query($query); if (! $qid && ! $silent) { if ($DB_DEBUG) { echo "
" . htmlspecialchars($query) . ""; echo "
mysql Error: ", mysql_error(); } else { echo "
This script cannot continue, terminating.";
die();
}
}
return $qid;
}
function db_fetch_array($qid) {
return mysql_fetch_array($qid);
}
function db_fetch_row($qid) {
return mysql_fetch_row($qid);
}
function db_fetch_assoc($qid) {
return mysql_fetch_assoc($qid);
}
function db_fetch_object($qid) {
return mysql_fetch_object($qid);
}
function db_num_rows($qid) {
return mysql_num_rows($qid);
}
function db_affected_rows() {
return mysql_affected_rows();
}
function db_insert_id() {
return mysql_insert_id();
}
function db_free_result($qid) {
mysql_free_result($qid);
}
function db_num_fields($qid) {
return mysql_num_fields($qid);
}
function db_field_name($qid, $fieldno) {
return mysql_field_name($qid, $fieldno);
}
function db_data_seek($qid, $row) {
if (db_num_rows($qid)) { return mysql_data_seek($qid, $row); }
}
class Paging {
var $int_num_result; // Number of result to show per page
var $int_nbr_row; // Total number of items (generally a sql count from db)
var $int_cur_position; // Current position in recordset
var $str_table_bgcolor; // Color of the html table contour, default to black
var $str_table_width; // Width of the HTML table, default to 400 pixel
var $img_source_next = "
";
var $img_source_previous = "
";
// ------------------------------------------------------------------------------------------ Constructor
//
function Paging( $int_nbr_row, $int_cur_position, $int_num_result, $str_table_bgcolor = "#000000", $str_table_width = 400 ){
$this->int_nbr_row = $int_nbr_row;
$this->int_num_result = $int_num_result;
$this->int_cur_position = $int_cur_position;
$this->str_table_bgcolor = $str_table_bgcolor;
$this->str_table_width = $str_table_width;
}
// ------------------------------------------------------------------------------------------ getNumberOfPage()
function getNumberOfPage(){
$int_nbr_page = ceil($this->int_nbr_row / $this->int_num_result);
return $int_nbr_page;
}
// ------------------------------------------------------------------------------------------ getCurrentPage()
// T
function getCurrentPage(){
$int_cur_page = ceil(( $this->int_cur_position * $this->getNumberOfPage() ) / $this->int_nbr_row);
return $int_cur_page;
}
// --------------------------------------------------------------------------------------------------- openTable()
function openTable(){
global $CFG;
$ret = "
| str_table_bgcolor ."\">"
." |