ต้องการให้แสดงข้อมูลเฉพาะเดือนที่ยังไม่ได้จ่ายเงิน ต้องทำยังไงครับ (เดือนที่จ่ายเงินแล้วคือdate_pay)

ต้องการให้แสดงข้อมูลเฉพาะเดือนที่ยังไม่ได้จ่ายเงิน ต้องทำยังไงครับ (เดือนที่จ่ายเงินแล้วคือdate_pay)
[open_code]<?
ob_start();
session_start();

include("include/connect.php");

if($_SESSION['admin'] != "admin"){
    ?>
    <form action="log_admin.php" method="post" name="myform">
    password : <input name="txtpass" id="txtpass" type="password" /> <input value="login" name="bt" type="submit" />
    </form>
    
    <?    exit();
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>เมืองนนท์อพาร์ทเม้นท์</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script>
function pay(doc_id)
{
if(confirm("ห้อง"+doc_id+"ได้ชำระเงินเรียบร้อยแล้ว")==true)
{
window.location = 'pay.php?doc_id='+doc_id;
}
else
{
alert('You selected to cancel.');
}
}
</script>
</head>

<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center"><? require_once("banner.inc.php"); ?></td>
  </tr>
  <tr>
    <td align="center"><? require_once("menu_admin.inc.php"); ?></td>
  </tr>
  <tr>
    <td align="center"><br />
<br />
<br />
<br />

      <table width="1020" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="86" align="center" bgcolor="#66FF33">หมายเลขห้อง</td>
          <td width="122" align="center" bgcolor="#66FF33">ชื่อ-สกุล</td>
          <td width="90" align="center" bgcolor="#66FF33">เบอร์โทร</td>
          <td width="86" align="center" bgcolor="#66FF33">ราคาค่าห้อง</td>
          <td width="115" align="center" bgcolor="#66FF33">ค่าไฟ(เดือนนี้)</td>
          <td width="108" align="center" bgcolor="#66FF33">ค่าน้ำ(เดือนนี้)</td>
          <td width="95" align="center" bgcolor="#66FF33">ยอด</td>
          <td width="120" align="center" bgcolor="#66FF33">วันเดือนปี</td>
          <td width="120" align="center" bgcolor="#66FF33">สถานะ</td>
          <td width="78" align="center" bgcolor="#66FF33">เครื่องมือ</td>
        </tr>
      <?
      $sql = "SELECT A.doc_id , A.price , A.status , B.per_id , B.f_name , B.l_name ,  B.tel  FROM  room A, user B WHERE A.status=B.per_id ORDER BY A.doc_id ASC ";
     $result = mysql_query($sql);
     $row = mysql_fetch_array($result);
    
     function fn_bill($doc_id,$per_id,$value){
         include("include/connect.php");
         $date = date("Y-m");
         $ss = "SELECT * FROM bill WHERE room_id='$doc_id' AND per_id='$per_id' AND date_bill = '$date' ";
         $rr = mysql_query($ss);
         $roow = mysql_fetch_array($rr);
         $numm = mysql_num_rows($rr);
         if($numm == 0){
             $return = "ยังไม่ได้คำนวน";
             }else if($numm != 0 && $value == "fire"){
             $return = "$roow[$value]";
                 }else if($numm != 0 && $value == "water"){
             $return = "$roow[$value]";
                 }else if($numm != 0 && $value == "price"){
             $return = "$roow[$value]";
                 }else if($numm != 0 && $value == "status"){
                                if($roow['date_pay'] == ""){
                                    $return = "ค้างชำระ";
                                    }else{
                                        $return = "ชำระแล้ว";
                                        }
                 }else if($numm != 0 && $value == "date_pay"){            
                                    $return = "$roow[$value]";
                 }
                
                
         return $return;
     }
      
      do{
      ?>
      
        <tr>
          <td align="center"><? echo $row['doc_id']; ?> </td>
          <td align="center"><? echo $row['f_name']; ?>  <? echo $row['l_name']; ?></td>
          <td align="center"><? echo $row['tel']; ?></td>
          <td align="center"><? echo $row['price']; ?></td>
          <td align="center">
          <?
          echo fn_bill("$row[doc_id]","$row[per_id]","fire");
          ?>    
           </td>
          <td align="center"><?
          echo fn_bill("$row[doc_id]","$row[per_id]","water");
          ?></td>
          <td align="center"><?
          echo fn_bill("$row[doc_id]","$row[per_id]","price");
          ?></td>
          <td align="center"><?
          echo fn_bill("$row[doc_id]","$row[per_id]","date_pay");
          ?></td>
          <td align="center">
          <?
          echo fn_bill("$row[doc_id]","$row[per_id]","status");
          ?>    
           </td>
          <td align="center">
          <a href="process.php?doc_id=<? echo $row[doc_id]; ?>&per_id=<? echo $row[per_id]; ?>">
          <img src="image/b_browse.png" width="16" height="16" border="0" title="คำนวน"/></a> |
          <a href="#" onClick="pay(<? echo $row[doc_id]; ?>);">
          <img src="image/b_edit.png" width="16" height="16" border="0" title="จ่ายแล้ว"/></a>|
          <a href="bill.php?doc_id=<? echo $row[doc_id]; ?>" >
          <img src="image/annoicon.gif" width="20" height="20" border="0" title="ออกบิล"/>
          </a>
          
          </td>
        </tr>
        <?
      }while($row = mysql_fetch_array($result));
        ?>
        
      </table>
      <p> </p>
      <p> </p>
      <p> </p>
      <p> </p>
      <p> </p>
      <p> </p>
      <p> </p>
    <p> </p></td>
  </tr>
  <tr>
    <td align="center"><? require_once("footer.inc.php"); ?></td>
  </tr>
</table>
</body>

</html>
[/close_code]
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่