php function fcur sign value if value return sign number_format value

 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
<?php
function fcur($sign, $value){
if ($value > 0){
return "+" . $sign . number_format($value, 2);
}
else {
return "-" . $sign . number_format($value, 2);
}
}
function w2log($filename, $content){
if (is_array($content) && !empty($content)) {
if ($fp = @fopen(FULL_PATH."/log/".$filename, "a+", true)) {
foreach ($content as $name => $value) {
fwrite($fp, date("d.m.Y H:i:s").": ".$name. (empty($value) ? '' : ' = '.$value) ."\n");
}
fclose($fp);
return true;
}
}
return false;
}
function db_query($sql) {
if (mysql_query($sql)) {
return true;
} else {
w2log("sql_log-".time().".php",array("Invalid SQL: "=>"$sql"));
return false;
}
}
function func_query($sql){
$result = false;
if ($res = mysql_query($sql)) {
if (mysql_num_rows($res)){
while ($row = mysql_fetch_assoc($res)) {
$result[] = $row;
}
}
return $result;
} else {
w2log("sql_log-".time().".php",array("Invalid SQL: "=>"$sql"));
return false;
}
}
function func_query_first($sql){
$result = false;
if ($res = mysql_query($sql)) {
if (mysql_num_rows($res)){
if ($row = mysql_fetch_assoc($res)) {
$result = $row;
}
}
return $result;
} else {
w2log("sql_log-".time().".php",array("Invalid SQL: "=>"$sql"));
return false;
}
}
function func_query_first_cell($sql){
$result = false;
if ($res = mysql_query($sql)) {
if (mysql_num_rows($res)){
if ($row = mysql_fetch_row($res)) {
$result = $row[0];
}
}
return $result;
} else {
w2log("sql_log-".time().".php",array("Invalid SQL: "=>"$sql"));
return false;
}
}
?>