01.
if
(!function_exists(
"GetSQLValueString"
)) {
02.
function
GetSQLValueString(
$theValue
,
$theType
,
$theDefinedValue
=
""
,
$theNotDefinedValue
=
""
)
03.
{
04.
if
(PHP_VERSION < 6) {
05.
$theValue
= get_magic_quotes_gpc() ?
stripslashes
(
$theValue
) :
$theValue
;
06.
}
07.
08.
$theValue
= function_exists(
"mysql_real_escape_string"
) ? mysql_real_escape_string(
$theValue
) : mysql_escape_string(
$theValue
);
09.
10.
switch
(
$theType
) {
11.
case
"text"
:
12.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
13.
break
;
14.
case
"long"
:
15.
case
"int"
:
16.
$theValue
= (
$theValue
!=
""
) ?
intval
(
$theValue
) :
"NULL"
;
17.
break
;
18.
case
"double"
:
19.
$theValue
= (
$theValue
!=
""
) ? doubleval(
$theValue
) :
"NULL"
;
20.
break
;
21.
case
"date"
:
22.
$theValue
= (
$theValue
!=
""
) ?
"'"
.
$theValue
.
"'"
:
"NULL"
;
23.
break
;
24.
case
"defined"
:
25.
$theValue
= (
$theValue
!=
""
) ?
$theDefinedValue
:
$theNotDefinedValue
;
26.
break
;
27.
}
28.
29.
return
$theValue
;
30.
}
31.
}
32.
33.
$editFormAction
=
$_SERVER
[
'PHP_SELF'
];
34.
if
(isset(
$_SERVER
[
'QUERY_STRING'
])) {
35.
$editFormAction
.=
"?"
. htmlentities(
$_SERVER
[
'QUERY_STRING'
]);
36.
}
37.
38.
if
((isset(
$_POST
[
"MM_insert"
])) && (
$_POST
[
"MM_insert"
] ==
"adduser3"
)) {
39.
$insertSQL
= sprintf(
"INSERT INTO add_service (date, depat, depat1, time_sup, name_sup, code_mc, name_mc, status_sup, com_sup, status_mn) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
,
40.
GetSQLValueString(
$_POST
[
'Tdate'
],
"date"
),
41.
GetSQLValueString(
$_POST
[
'S_depat'
],
"date"
),
42.
GetSQLValueString(
$_POST
[
'list1'
],
"text"
),
43.
GetSQLValueString(
$_POST
[
'T_sup'
],
"text"
),
44.
GetSQLValueString(
$_POST
[
'S_sup'
],
"text"
),
45.
GetSQLValueString(
$_POST
[
'list2'
],
"text"
),
46.
GetSQLValueString(
$_POST
[
'list3'
],
"text"
),
47.
GetSQLValueString(
$_POST
[
'St_sup'
],
"text"
),
48.
GetSQLValueString(
$_POST
[
'T_com'
],
"text"
),
49.
GetSQLValueString(
$_POST
[
'TStatus_mn'
],
"text"
)
50.
51.
);
52.
53.
mysql_select_db(
$database_IT
,
$IT
);
54.
$Result1
= mysql_query(
$insertSQL
,
$IT
)
or
die
(mysql_error());
55.
56.
$insertGoTo
=
"index.php"
;
57.
58.
if
(isset(
$_SERVER
[
'QUERY_STRING'
])) {
59.
$insertGoTo
.= (
strpos
(
$insertGoTo
,
'?'
)) ?
"&"
:
"?"
;
60.
$insertGoTo
.=
$_SERVER
[
'QUERY_STRING'
];
61.
}
62.
header(sprintf(
"Location: %s"
,
$insertGoTo
));
63.
}
64.
65.
$maxRows_User
= 100;
66.
$pageNum_User
= 0;
67.
if
(isset(
$_GET
[
'pageNum_User'
])) {
68.
$pageNum_User
=
$_GET
[
'pageNum_User'
];
69.
}
70.
$startRow_User
=
$pageNum_User
*
$maxRows_User
;
71.
72.
mysql_select_db(
$database_IT
,
$IT
);
73.
$query_User
=
"SELECT * FROM add_service ORDER BY id DESC"
;
74.
$query_limit_User
= sprintf(
"%s LIMIT %d, %d"
,
$query_User
,
$startRow_User
,
$maxRows_User
);
75.
$User
= mysql_query(
$query_limit_User
,
$IT
)
or
die
(mysql_error());
76.
$row_User
= mysql_fetch_assoc(
$User
);
77.
78.
if
(isset(
$_GET
[
'totalRows_User'
])) {
79.
$totalRows_User
=
$_GET
[
'totalRows_User'
];
80.
}
else
{
81.
$all_User
= mysql_query(
$query_User
);
82.
$totalRows_User
= mysql_num_rows(
$all_User
);
83.
}
84.
$totalPages_User
=
ceil
(
$totalRows_User
/
$maxRows_User
)-1;
85.
86.
?>