"자작"에 가계부 프로그램 질문드립니다. 정보
"자작"에 가계부 프로그램 질문드립니다.관련링크
본문
이놈이 회원마다 작성하도록 되있는데
관리자가 작성하면 일반회원이 모두 볼수있으면 합니다.
config 파일에는 비회원제일 경우도 가능한것 같은데 잘 안되더군요
<?
// 상대 경로
$g4_path = ".."; //본인에 맞게 경로수정
include_once("$g4_path/common.php");
// 상대 경로
$g4_path = ".."; //본인에 맞게 경로수정
include_once("$g4_path/common.php");
$cash_sub = "가계부";
// 회원제일 경우
//$cash_if = " where id_fk='$member[mb_id]' ";
//$cash_if2 = " and ";
//$cash_name = $member[mb_name]."님의 ";
//$cash_if = " where id_fk='$member[mb_id]' ";
//$cash_if2 = " and ";
//$cash_name = $member[mb_name]."님의 ";
// 비회원제일 경우
$cash_if = " ";
$cash_if2 = " where ";
$cash_name = " 우리들 ";
?>
파일중 일부만 올립니다.
<?
include_once ("config.php");
include_once ("config.php");
if(!$member[mb_id]) {
alert("회원 로그인 후에 접속해 주세요.", $g4[path]);
}
include "util.php";
$html_title = "가계부 목록";
include_once("$g4[path]/head_guide.php");
?>
alert("회원 로그인 후에 접속해 주세요.", $g4[path]);
}
include "util.php";
$html_title = "가계부 목록";
include_once("$g4[path]/head_guide.php");
?>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkall() {
var form = document.cash;
for (i=0; i < form.elements.length; i++) {
if (form.elements[i].name =="del_num[]") {
form.elements[i].checked = true;
}
}
return;
}
function uncheckall() {
var form = document.cash;
for (i=0; i < form.elements.length; i++) {
if (form.elements[i].name =="del_num[]") {
form.elements[i].checked = false;
}
}
return;
}
//-->
</SCRIPT>
<!--
function checkall() {
var form = document.cash;
for (i=0; i < form.elements.length; i++) {
if (form.elements[i].name =="del_num[]") {
form.elements[i].checked = true;
}
}
return;
}
function uncheckall() {
var form = document.cash;
for (i=0; i < form.elements.length; i++) {
if (form.elements[i].name =="del_num[]") {
form.elements[i].checked = false;
}
}
return;
}
//-->
</SCRIPT>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr><td class="lordfont3bold" height="29">
<img src="image/iconfom1.gif"> 가계부
</td></tr></table>
<table width="90%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%"> <img src="image/search_im_001.gif">오늘은 <span class="name"><?=date('Y년 m월 d일')?></span> 입니다.</td>
<td align="right"><a href="cashbook_write.php"><img src="image/house_bu_001.gif" border="0"></a></td>
</tr>
</table>
<table width="90%" cellspacing="0" cellpadding="0">
<tr><td colspan=5 height=3 bgcolor=#ff9933></td></tr>
<tr bgcolor=#F8F8F8>
<td align="center" height='25' width="50"> </td>
<td align="center" height='25' width="55"><b><font color="#006699">구분</font></b></td>
<td align="center" height='25' width="100"><b><font color="#006699">일자</font></b></td>
<td align="center" ><b><font color="#006699">항목</font></b></td>
<td align="center" width="90"><b><font color="#006699">금액</font></b></td>
</tr>
<tr><td colspan=5 height=1 bgcolor=#D5D5D5></td></tr>
</table>
<?
$sql_1 = "select * from g4_plugin_cashbook $cash_if ";
$res_1 = sql_query($sql_1);
$total_num = mysql_num_rows($res_1);
if($total_num){ //자료가 존재 경우
?>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<form name='cash' method='post' action='cashbook_del.php'>
<?
$p_scale=15;
if ($page == ''){
$page=1;
}
$cpage = intval($page);
$totalpage = intval($total_num/$p_scale);
if ($totalpage*$p_scale != $total_num)
$totalpage = $totalpage + 1;
if ($cpage ==1) {
$cline = 0 ;
} else {
$cline = ($cpage*$p_scale) - $p_scale ;
}
$limit=$cline+$p_scale;
if ($limit >= $total_num)
$limit=$total_num;
$p_scale1 = $limit - $cline;
$sql_2 = "select * from g4_plugin_cashbook where id_fk='$member[mb_id]' ";
$sql_2 .= " order by c_date desc limit $cline,$p_scale1";
$res_2 = sql_query($sql_2);
<tr>
<td valign="top" align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr><td class="lordfont3bold" height="29">
<img src="image/iconfom1.gif"> 가계부
</td></tr></table>
<table width="90%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%"> <img src="image/search_im_001.gif">오늘은 <span class="name"><?=date('Y년 m월 d일')?></span> 입니다.</td>
<td align="right"><a href="cashbook_write.php"><img src="image/house_bu_001.gif" border="0"></a></td>
</tr>
</table>
<table width="90%" cellspacing="0" cellpadding="0">
<tr><td colspan=5 height=3 bgcolor=#ff9933></td></tr>
<tr bgcolor=#F8F8F8>
<td align="center" height='25' width="50"> </td>
<td align="center" height='25' width="55"><b><font color="#006699">구분</font></b></td>
<td align="center" height='25' width="100"><b><font color="#006699">일자</font></b></td>
<td align="center" ><b><font color="#006699">항목</font></b></td>
<td align="center" width="90"><b><font color="#006699">금액</font></b></td>
</tr>
<tr><td colspan=5 height=1 bgcolor=#D5D5D5></td></tr>
</table>
<?
$sql_1 = "select * from g4_plugin_cashbook $cash_if ";
$res_1 = sql_query($sql_1);
$total_num = mysql_num_rows($res_1);
if($total_num){ //자료가 존재 경우
?>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<form name='cash' method='post' action='cashbook_del.php'>
<?
$p_scale=15;
if ($page == ''){
$page=1;
}
$cpage = intval($page);
$totalpage = intval($total_num/$p_scale);
if ($totalpage*$p_scale != $total_num)
$totalpage = $totalpage + 1;
if ($cpage ==1) {
$cline = 0 ;
} else {
$cline = ($cpage*$p_scale) - $p_scale ;
}
$limit=$cline+$p_scale;
if ($limit >= $total_num)
$limit=$total_num;
$p_scale1 = $limit - $cline;
$sql_2 = "select * from g4_plugin_cashbook where id_fk='$member[mb_id]' ";
$sql_2 .= " order by c_date desc limit $cline,$p_scale1";
$res_2 = sql_query($sql_2);
for ($i=1;$phj = mysql_fetch_array($res_2);$i++){
$num = $phj['num'];
$gubun = $phj['gubun'];
$subject = $phj['subject'];
$money = $phj['money'];
$c_date = $phj['c_date'];
$year = substr($c_date,0,4);
$month = substr($c_date,4,2);
$day = substr($c_date,-2);
if($gubun=='1'){
$gubun = '수입';
}
else{
$gubun ='지출';
}
?>
<tr>
<td width="5" align="center" height="23"> </td>
<td width="40" align="center" height="23">
<input type="checkbox" name="del_num[]" value="<?=$num?>"></td>
<td width="85" align="center" height="23"><?=$gubun?></td>
<td width="85" align="center" height="23"><?=$year?>.<?=$month?>.<?=$day?></td>
<td height="23"><?=$subject?> </td>
<td width="95" align="center" height="23"><?=number_format($money)?>원</td>
</tr>
<tr>
<td colspan="6" background="image/table_bg_001.gif"></td>
</tr>
<?
}
mysql_free_result($res_2);
?>
<tr>
<td colspan="6" align=center height='20'>
<?
$url = "cashbook_001.php";
page_avg1($totalpage,$cpage,$url);
?>
</td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="./cashbook/image/table_im_004.gif"></td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="223">
<input type="button" value="전체선택" onclick="javascript:checkall()">
<input type="button" value="선택해제" onclick="javascript:uncheckall()">
</td>
<td width="198" align="Center"> </td>
<td width="87" align="center"><input type=image src="image/delete_bu_001.gif" vspace="5"></td>
</tr>
</form>
</table>
<br>
<br>
<?
$today = date('Ymd');
?>
<table width="90%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%"> <img src="image/search_im_001.gif">오늘은
<span class="name"><?=date('Y년 m월 d일')?></span> 입니다.</td>
<td align="right"><a href="cashbook_write.php"><img src="image/house_bu_001.gif" border="0"></a></td>
</tr>
</table>
<table width="88%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td colspan=2 height=3 bgcolor=#ff9933></td></tr>
<tr>
<td bgcolor="#F8F8F8" align="center" width="32%" height="25"><b>오늘 수입</b></td>
<td bgcolor="#FFFFFF" align="right" width="68%" height="25">
<?
$query2 ="select sum(money) as a_sum from g4_plugin_cashbook ";
$query2 .=" where id_fk='$member[mb_id]' ";
$query2 .=" and c_date='$today' and gubun='1' ";
$result2 = sql_query($query2);
$add_sum = mysql_result($result2,0,"a_sum");
echo(number_format($add_sum));
?> 원 </td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#d5d5d5></td></tr>
<tr>
<td bgcolor="#F8F8F8" align="center" width="32%" height="25"> <b>오늘 지출</b><br>
</td>
<td bgcolor="#FFFFFF" align="right" width="68%" height="25">
<?
$query3 ="select sum(money) as s_sum from g4_plugin_cashbook ";
$query3 .=" where id_fk='$member[mb_id]' ";
$query3 .=" and c_date='$today' and gubun='2' ";
$result3 = sql_query($query3);
$sub_sum = mysql_result($result3,0,"s_sum");
echo(number_format($sub_sum));
?> 원 </td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#d5d5d5></td></tr>
<tr>
<td align="center" height="30" bgcolor="#F8F8F8><font color="#FF6600"><b>토탈
합계</b></font></td>
<td align="right" class="name" bgcolor="#FFFFFF" height="30">
<?
$avg_money = $add_sum - $sub_sum;
echo(number_format($avg_money));
?>원</td>
</tr>
<tr><td colspan=2 height=2 bgcolor=#d5d5d5></td></tr>
</table>
</td>
</tr>
</table>
<br>
<table width="88%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<a href="cashbook_month.php"><img src="image/house_bu_002.gif" border="0"></a>
<a href="cashbook_year.php"><img src="image/house_bu_003.gif" border="0"></a>
<a href="cashbook_period.php"><img src="image/house_bu_004.gif" border="0"></a></td>
</tr>
</table>
<? } else{ ?>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"> <img src="image/blank_im_002.gif"><br>
등록된 내용이 없습니다.<br>
아래의 가계부 쓰기를 눌러 가계부를 쓰세요.</td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td align="center"><a href="cashbook_write.php"><img src="image/house_bu_001.gif" border="0"></a></td>
</tr>
</table>
<? } ?>
</td>
</tr>
</table>
<? include_once("$g4[path]/tail_comm.php"); ?>
$num = $phj['num'];
$gubun = $phj['gubun'];
$subject = $phj['subject'];
$money = $phj['money'];
$c_date = $phj['c_date'];
$year = substr($c_date,0,4);
$month = substr($c_date,4,2);
$day = substr($c_date,-2);
if($gubun=='1'){
$gubun = '수입';
}
else{
$gubun ='지출';
}
?>
<tr>
<td width="5" align="center" height="23"> </td>
<td width="40" align="center" height="23">
<input type="checkbox" name="del_num[]" value="<?=$num?>"></td>
<td width="85" align="center" height="23"><?=$gubun?></td>
<td width="85" align="center" height="23"><?=$year?>.<?=$month?>.<?=$day?></td>
<td height="23"><?=$subject?> </td>
<td width="95" align="center" height="23"><?=number_format($money)?>원</td>
</tr>
<tr>
<td colspan="6" background="image/table_bg_001.gif"></td>
</tr>
<?
}
mysql_free_result($res_2);
?>
<tr>
<td colspan="6" align=center height='20'>
<?
$url = "cashbook_001.php";
page_avg1($totalpage,$cpage,$url);
?>
</td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="./cashbook/image/table_im_004.gif"></td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="223">
<input type="button" value="전체선택" onclick="javascript:checkall()">
<input type="button" value="선택해제" onclick="javascript:uncheckall()">
</td>
<td width="198" align="Center"> </td>
<td width="87" align="center"><input type=image src="image/delete_bu_001.gif" vspace="5"></td>
</tr>
</form>
</table>
<br>
<br>
<?
$today = date('Ymd');
?>
<table width="90%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="50%"> <img src="image/search_im_001.gif">오늘은
<span class="name"><?=date('Y년 m월 d일')?></span> 입니다.</td>
<td align="right"><a href="cashbook_write.php"><img src="image/house_bu_001.gif" border="0"></a></td>
</tr>
</table>
<table width="88%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0">
<tr><td colspan=2 height=3 bgcolor=#ff9933></td></tr>
<tr>
<td bgcolor="#F8F8F8" align="center" width="32%" height="25"><b>오늘 수입</b></td>
<td bgcolor="#FFFFFF" align="right" width="68%" height="25">
<?
$query2 ="select sum(money) as a_sum from g4_plugin_cashbook ";
$query2 .=" where id_fk='$member[mb_id]' ";
$query2 .=" and c_date='$today' and gubun='1' ";
$result2 = sql_query($query2);
$add_sum = mysql_result($result2,0,"a_sum");
echo(number_format($add_sum));
?> 원 </td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#d5d5d5></td></tr>
<tr>
<td bgcolor="#F8F8F8" align="center" width="32%" height="25"> <b>오늘 지출</b><br>
</td>
<td bgcolor="#FFFFFF" align="right" width="68%" height="25">
<?
$query3 ="select sum(money) as s_sum from g4_plugin_cashbook ";
$query3 .=" where id_fk='$member[mb_id]' ";
$query3 .=" and c_date='$today' and gubun='2' ";
$result3 = sql_query($query3);
$sub_sum = mysql_result($result3,0,"s_sum");
echo(number_format($sub_sum));
?> 원 </td>
</tr>
<tr><td colspan=2 height=1 bgcolor=#d5d5d5></td></tr>
<tr>
<td align="center" height="30" bgcolor="#F8F8F8><font color="#FF6600"><b>토탈
합계</b></font></td>
<td align="right" class="name" bgcolor="#FFFFFF" height="30">
<?
$avg_money = $add_sum - $sub_sum;
echo(number_format($avg_money));
?>원</td>
</tr>
<tr><td colspan=2 height=2 bgcolor=#d5d5d5></td></tr>
</table>
</td>
</tr>
</table>
<br>
<table width="88%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
<a href="cashbook_month.php"><img src="image/house_bu_002.gif" border="0"></a>
<a href="cashbook_year.php"><img src="image/house_bu_003.gif" border="0"></a>
<a href="cashbook_period.php"><img src="image/house_bu_004.gif" border="0"></a></td>
</tr>
</table>
<? } else{ ?>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"> <img src="image/blank_im_002.gif"><br>
등록된 내용이 없습니다.<br>
아래의 가계부 쓰기를 눌러 가계부를 쓰세요.</td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td align="center"><a href="cashbook_write.php"><img src="image/house_bu_001.gif" border="0"></a></td>
</tr>
</table>
<? } ?>
</td>
</tr>
</table>
<? include_once("$g4[path]/tail_comm.php"); ?>
댓글 전체
$sql_2 = "select * from g4_plugin_cashbook where id_fk='$member[mb_id]' ";
$query3 .=" where id_fk='$member[mb_id]' ";
을
$sql_2 = "select * from g4_plugin_cashbook $cash_if ";
$query3 .=" $cash_if ";
로 바꾸어 주면 되지 않을까 합니다.
제가 사용하질 않아서 확인은 불가 합니다...ㅠ.ㅠ
소스상으로는 가능할 듯 합니다만....
$query3 .=" where id_fk='$member[mb_id]' "; 아래에 and 문은 and를 제거하셔야 할듯 합니다.(2군데인가 3군데....ㅎㅎㅎ)
$query3 .=" where id_fk='$member[mb_id]' ";
을
$sql_2 = "select * from g4_plugin_cashbook $cash_if ";
$query3 .=" $cash_if ";
로 바꾸어 주면 되지 않을까 합니다.
제가 사용하질 않아서 확인은 불가 합니다...ㅠ.ㅠ
소스상으로는 가능할 듯 합니다만....
$query3 .=" where id_fk='$member[mb_id]' "; 아래에 and 문은 and를 제거하셔야 할듯 합니다.(2군데인가 3군데....ㅎㅎㅎ)