-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.php
More file actions
executable file
·107 lines (88 loc) · 2.89 KB
/
Copy pathlib.php
File metadata and controls
executable file
·107 lines (88 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?
// db setting
$host_name = "db659055917.db.1and1.com";
$database = "db659055917";
$user_name = "dbo659055917";
$password = "Instabook0";
$connect = mysqli_connect($host_name, $user_name, $password, $database);
if(mysqli_connect_errno())
{
echo 'MySQL Server error: '.mysqli_connect_error().'<br/>';
}
else
{
echo 'MySQL Server Connected.<br/>';
}
// access and select database function
function sql_connect($db_host, $db_user, $db_pass, $db_name)
{
$result = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
//mysql_select_db("test") or die(mysql_error());
return $result;
}
// query functions
function sql_query($sql)
{
global $connect;
// echo "<pre>Debug1: $sql</pre>";
// $connect = mysqli_connect($host_name, $user_name, $password, $database);
$result = mysqli_query($connect, $sql);// or die("<p>$sql<p>" . mysqli_errno() . " : " . mysqli_error() . "<p>error file : $_SERVER[PHP_SELF]");
if ( false===$result ) {
printf("error: %s\n", mysqli_error($connect));
}else {
// echo 'done...........';
}
return $result;
}
// return total count
function sql_total($sql)
{
global $connect;
$result_total = sql_query($sql, $connect);
$data_total = mysql_fetch_array($result_total);
$total_count = $data_total[cnt];
return $total_count;
}
// paging function for posting pages
function paging($page, $page_row, $page_scale, $total_count, $ext = '')
{
// total number of pages
$total_page = ceil($total_count / $page_row);
// initialize variant which prints paging
$paging_str = "";
// first page link
if ($page > 1) {
$paging_str .= "<a href='".$_SERVER[PHP_SELF]."?page=1&'".$ext.">First</a>";
}
// Start page
$start_page = ( (ceil( $page / $page_scale ) - 1) * $page_scale ) + 1;
// End page
$end_page = $start_page + $page_scale - 1;
if ($end_page >= $total_page) $end_page = $total_page;
// Previous Link
if ($start_page > 1){
$paging_str .= " <a href='".$_SERVER[PHP_SELF]."?page=".($start_page - 1)."&'".$ext.">Previous</a>";
}
// the number of link pages
if ($total_page > 1) {
for ($i=$start_page;$i<=$end_page;$i++) {
// other link pages
if ($page != $i){
$paging_str .= " <a href='".$_SERVER[PHP_SELF]."?page=".$i."&'".$ext."><span>$i</span></a>";
// set the number as bold type for current page
}else{
$paging_str .= " <b>$i</b> ";
}
}
}
// Next Link
if ($total_page > $end_page){
$paging_str .= " <a href='".$_SERVER[PHP_SELF]."?page=".($end_page + 1)."&'".$ext.">Next</a>";
}
// Last page
if ($page < $total_page) {
$paging_str .= " <a href='".$_SERVER[PHP_SELF]."?page=".$total_page."&'".$ext.">Last</a>";
}
return $paging_str;
}
?>