Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > การเเสดงผลเมื่อค้นหาข้อมูลไม่พบโดยจะให้เเสดงข้อความบนฟอร์มว่าไม่พบข้อมูล



 

การเเสดงผลเมื่อค้นหาข้อมูลไม่พบโดยจะให้เเสดงข้อความบนฟอร์มว่าไม่พบข้อมูล

 



Topic : 126175



โพสกระทู้ ( 0 )
บทความ ( 0 )



สถานะออฟไลน์




ทำฟอร์มค้นหาข้อมูล จากเดือนเเละปีครับ โดยดูจาก month(Date_Pay) กับ year(Date_Pay) ***Date_Pay เก็บวันที่ในดาต้าเบสครับ

อยากให้เวลาไม่พบข้อมูลเเล้ว เเสดงข้อความไม่พบข้อมูลบนฟอร์มหน่ะครับ ต้องเพิ่มตรงไหน

Code (PHP)
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>::ข้อมูลรายรับ-จ่าย::</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#tabs" ).tabs();
  } );
  </script>
</head>
<style type="text/css">
html, body { 
   height: 100%; /* ให้ html และ body สูงเต็มจอภาพไว้ก่อน */
   width: 100%;
   margin: 0;
   padding: 0;
}
.wrapper {
   display: block;
   min-height: 100%; /* real browsers */
   height: auto !important; /* real browsers */
   height: 100%; /* IE6 bug */
   margin-bottom: -20px; /* กำหนด margin-bottom ให้ติดลบเท่ากับความสูงของ footer */
}
.footer {
   height: 20px; /* ความสูงของ footer */
   display: block;
   text-align: center;
}
body 
{
background-image : url('images/green21.jpg');
background-attachment : fixed
}
</style>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">

<br>
<?
 include'function.php';
?>
<div align="center">
<div id="tabs"  style="width:1200px;">
  <ul style="background-color:lightgreen;height:40px;text-align:center;">
  <p></p><h4><b><font color="darkgreen">ค่าเช่าประจำเดือน</font></b></h4>
    <div align="center"><li></li></div>
  </ul>
  <div id="tabs-1">
<?
$monthai[1] = "มกราคม";$monthai[2] = "กุมภาพันธ์";$monthai[3] = "มีนาคม";$monthai[4] = "เมษายน";$monthai[5] = "พฤษภาคม";$monthai[6] = "มิถุนายน";$monthai[7] = "กรกฎาคม";$monthai[8] = "สิงหาคม";$monthai[9] = "กันยายน";$monthai[10] = "ตุลาคม";$monthai[11] = "พฤศจิกายน";$monthai[12] = "ธันวาคม";
?>
<br>
<div align="center">
<form name="frmSearch" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
  <table  style="width:1050px;" class="table table-striped table-bordered">
    <tr>
      <td align="center" bgcolor="lightblue"><font size="3" color="darkblue"><b>เดือน</b></font>
      <select name="txtKeyword" style="height:30px;">
      <option value="">-- เดือน --</option>
            <option value="1">มกราคม</option>
            <option value="2">กุมภาพันธ์</option>
            <option value="3">มีนาคม</option>
            <option value="4">เมษายน</option>
            <option value="5">พฤษภาคม</option>
            <option value="6">มิถุนายน</option>
            <option value="7">กรกฎาคม</option>
            <option value="8">สิงหาคม</option>
            <option value="9">กันยายน</option>
            <option value="10">ตุลาคม</option>
            <option value="11">พฤศจิกายน</option>
            <option value="12">ธันวาคม</option>	
      </select>
      <font size="3" color="darkblue"><b>ปี</b></font>
      <select name="txtKeyword2" style="width:60px;height:30px;">
        <option value="">-- ปี --</option>
      <? for($i=2010;$i<=date("Y");$i++){ ?>
      <option value="<?= $i; ?>"><?= $i+543 ?></option>
      <? }?>
      </select> 
      &nbsp;&nbsp;
      <input type="submit" class="btn btn-success" value="ค้นหา">
      <a href="searchmonthtest.php">
      <input type="button" name="clear" class="btn btn-danger" value="เคลียร์">
      </a>
      </td>
    </tr>
  </table>
</form>
<?
if($_GET["txtKeyword"] and $_GET["txtKeyword2"] )
	{
	include 'connect.php';
	$month = $_GET["txtKeyword"];
  $year = $_GET["txtKeyword2"];
?>
<?
$strSQL = "SELECT * FROM tb_payment WHERE month(Date_Pay) = '$month' and year(Date_Pay) = '$year' ";
  $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
	<table style="width:1050px;" class="table table-striped table-bordered" >
	  <tr>
		<td width="91" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>รหัสค่าเช่า</b></font></div></td>
		<td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>วันที่ชำระเงิน</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ห้องพัก</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าห้องพัก<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าไฟฟ้า<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าน้ำประปา<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าขยะ<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าปรับ<br>(บาท)</b></font></div></td>
     <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>จำนวนเงิน<br>(บาท)</b></font></div></td>
	  </tr>
    <?
    while ($objResult = mysql_fetch_array($objQuery)){
      $payid = $objResult["Pay_ID"];
      $payidshow =  substr("00000".$payid,-5,5);
      $sumroomprice += (int)$objResult['Room_Price'];
      $sumelecprice += (int)$objResult['Elec_Price'];
      $sumwaterprice += (int)$objResult['Water_Price'];
      $sumbinprice += (int)$objResult['Bin_Price'];
      $sumlimitprice += (int)$objResult['Limit_Price'];
      $sumtotalprice += (int)$objResult['Sum_Price'];
    ?>
	  <tr>
		<td align="center"><?php echo $payidshow; ?></td>
		<td ><?php echo Daythai($objResult["Date_Pay"]);?></td>
    <td align="center">ห้อง <? echo $objResult["Room"];?>  </td>
    <td align="center"> <? echo number_format($objResult["Room_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Elec_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Water_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Bin_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Limit_Price"]);?>  </td>
    <td align="center"><?php echo number_format($objResult["Sum_Price"]);?></td>
	  </tr>
    <?
  }
    ?>
      <tr>
      <td style="border-left-color:white;border-right-color:white;border-bottom-color:white;"></td>
      <td style="border-bottom-color:white;"></td>
    <td bgcolor="lightblue" align="center"><font color="darkblue"><b>รวมเงิน</b></font></td>
    <td align="center"><b><u><?php echo number_format($sumroomprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumelecprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumwaterprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumbinprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumlimitprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumtotalprice); ?></u></b></td>
    </tr>
	</table>
  <br>
<?php
	mysql_close($objConnect);
}
?>
</div>
<br>
</div>
</div>



</div>
</div>
</div>
</body>
</html>









Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-01-27 23:49:11 By : siwatboss View : 585 Reply : 1
 

 

No. 1



โพสกระทู้ ( 738 )
บทความ ( 0 )



สถานะออฟไลน์


แบบนี้หรือเปล่าครับ


<?php

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>::ข้อมูลรายรับ-จ่าย::</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#tabs" ).tabs();
  } );
  </script>
</head>
<style type="text/css">
html, body { 
   height: 100%; /* ให้ html และ body สูงเต็มจอภาพไว้ก่อน */
   width: 100%;
   margin: 0;
   padding: 0;
}
.wrapper {
   display: block;
   min-height: 100%; /* real browsers */
   height: auto !important; /* real browsers */
   height: 100%; /* IE6 bug */
   margin-bottom: -20px; /* กำหนด margin-bottom ให้ติดลบเท่ากับความสูงของ footer */
}
.footer {
   height: 20px; /* ความสูงของ footer */
   display: block;
   text-align: center;
}
body 
{
background-image : url('images/green21.jpg');
background-attachment : fixed
}
</style>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">

<br>
<?
 include'function.php';
?>
<div align="center">
<div id="tabs"  style="width:1200px;">
  <ul style="background-color:lightgreen;height:40px;text-align:center;">
  <p></p><h4><b><font color="darkgreen">ค่าเช่าประจำเดือน</font></b></h4>
    <div align="center"><li></li></div>
  </ul>
  <div id="tabs-1">
<?
$monthai[1] = "มกราคม";$monthai[2] = "กุมภาพันธ์";$monthai[3] = "มีนาคม";$monthai[4] = "เมษายน";$monthai[5] = "พฤษภาคม";$monthai[6] = "มิถุนายน";$monthai[7] = "กรกฎาคม";$monthai[8] = "สิงหาคม";$monthai[9] = "กันยายน";$monthai[10] = "ตุลาคม";$monthai[11] = "พฤศจิกายน";$monthai[12] = "ธันวาคม";
?>
<br>
<div align="center">
<form name="frmSearch" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
  <table  style="width:1050px;" class="table table-striped table-bordered">
    <tr>
      <td align="center" bgcolor="lightblue"><font size="3" color="darkblue"><b>เดือน</b></font>
      <select name="txtKeyword" style="height:30px;">
      <option value="">-- เดือน --</option>
            <option value="1">มกราคม</option>
            <option value="2">กุมภาพันธ์</option>
            <option value="3">มีนาคม</option>
            <option value="4">เมษายน</option>
            <option value="5">พฤษภาคม</option>
            <option value="6">มิถุนายน</option>
            <option value="7">กรกฎาคม</option>
            <option value="8">สิงหาคม</option>
            <option value="9">กันยายน</option>
            <option value="10">ตุลาคม</option>
            <option value="11">พฤศจิกายน</option>
            <option value="12">ธันวาคม</option>	
      </select>
      <font size="3" color="darkblue"><b>ปี</b></font>
      <select name="txtKeyword2" style="width:60px;height:30px;">
        <option value="">-- ปี --</option>
      <? for($i=2010;$i<=date("Y");$i++){ ?>
      <option value="<?= $i; ?>"><?= $i+543 ?></option>
      <? }?>
      </select> 
      &nbsp;&nbsp;
      <input type="submit" class="btn btn-success" value="ค้นหา">
      <a href="searchmonthtest.php">
      <input type="button" name="clear" class="btn btn-danger" value="เคลียร์">
      </a>
      </td>
    </tr>
  </table>
</form>
<?
if($_GET["txtKeyword"] != "" && $_GET["txtKeyword2"] != "")
	{
	include 'connect.php';
	$month = $_GET["txtKeyword"];
  $year = $_GET["txtKeyword2"];
?>
<?
$strSQL = "SELECT * FROM tb_payment WHERE month(Date_Pay) = '$month' and year(Date_Pay) = '$year' ";
  $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
  $num = mysql_num_rows($objQuery);

  if($num >= 1){
  
?>
	<table style="width:1050px;" class="table table-striped table-bordered" >
	  <tr>
		<td width="91" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>รหัสค่าเช่า</b></font></div></td>
		<td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>วันที่ชำระเงิน</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ห้องพัก</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าห้องพัก<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าไฟฟ้า<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าน้ำประปา<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าขยะ<br>(บาท)</b></font></div></td>
    <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>ค่าปรับ<br>(บาท)</b></font></div></td>
     <td width="98" bgcolor="lightblue"><div align="center"><font color="darkblue"><b>จำนวนเงิน<br>(บาท)</b></font></div></td>
	  </tr>
    <?
    while ($objResult = mysql_fetch_array($objQuery)){
      $payid = $objResult["Pay_ID"];
      $payidshow =  substr("00000".$payid,-5,5);
      $sumroomprice += (int)$objResult['Room_Price'];
      $sumelecprice += (int)$objResult['Elec_Price'];
      $sumwaterprice += (int)$objResult['Water_Price'];
      $sumbinprice += (int)$objResult['Bin_Price'];
      $sumlimitprice += (int)$objResult['Limit_Price'];
      $sumtotalprice += (int)$objResult['Sum_Price'];
    ?>
	  <tr>
		<td align="center"><?php echo $payidshow; ?></td>
		<td ><?php echo Daythai($objResult["Date_Pay"]);?></td>
    <td align="center">ห้อง <? echo $objResult["Room"];?>  </td>
    <td align="center"> <? echo number_format($objResult["Room_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Elec_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Water_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Bin_Price"]);?>  </td>
    <td align="center"> <? echo number_format($objResult["Limit_Price"]);?>  </td>
    <td align="center"><?php echo number_format($objResult["Sum_Price"]);?></td>
	  </tr>
    <?
  }
    ?>
      <tr>
      <td style="border-left-color:white;border-right-color:white;border-bottom-color:white;"></td>
      <td style="border-bottom-color:white;"></td>
    <td bgcolor="lightblue" align="center"><font color="darkblue"><b>รวมเงิน</b></font></td>
    <td align="center"><b><u><?php echo number_format($sumroomprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumelecprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumwaterprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumbinprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumlimitprice); ?></u></b></td>
    <td align="center"><b><u><?php echo number_format($sumtotalprice); ?></u></b></td>
    </tr>
	</table>
  <br>
<?php
	mysql_close($objConnect);
  } else {

      /////////แสดงข้อความตรงนี้เมื่อไม่พบข้อมูล//////////
  
  }
}
?>
</div>
<br>
</div>
</div>



</div>
</div>
</div>
</body>
</html>






?>








แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-01-28 22:26:53 By : tomrambo
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : การเเสดงผลเมื่อค้นหาข้อมูลไม่พบโดยจะให้เเสดงข้อความบนฟอร์มว่าไม่พบข้อมูล
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่