 |
|
คือว่าระบบนี้ครับ ผมอยากให้ เพิ่มปีงบประมาณได้ไม่เกิน 1 ปีครับ เช่น
ตอนนี้ ปี 2557 ก็เพิ่ม งบปี 2557 2558 ได้
แต่ถ้าเกิน 2558 ไปก็ยังเพิ่มไม่ได้เป็นต้นครับ
ผมลองใช้ if else เพื่อเช็คครับ แต่ว่า ยังไงๆมันก็บันทึกลงฐานข้อมูลได้ครับอะครับ
อันนี้เป็นหน้า budgetadd.php ครับ
Code (PHP)
<table width="904" height="162" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="" class="tb">
<thead class="tb">
<tr class="tb">
<th width="170" height="28" class="style2">ปีงบประมาณ</th>
<th width="734" align="left"><input name="txtbudget" type="text" required="required" id="txtname3" OnKeyPress="return chkNumber(this)" value="25" size="4" maxlength="4" minlength="3"/>
<span class="style2">(เช่น :25xx)</span></th>
</tr>
</thead>
<tr class="tb">
<td height="31" class="style2">จำนวนงบประมาณ</td>
<td><input name="txtmoney" type="text" required="required" id="txtname5" OnKeyPress="return chkNumber(this)"/>
บาท</td>
</tr>
</table>
หน้านี้เป็น budget_saveadd.php ครับ
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require('connect.php');
?>
<?php
$txtbudget01 = $_POST['txtbudget'];
$date = date("Y") ;
$yearthai = $date+543 ;
$date01 = date("Y") ;
$yearthai01 = $date01+544 ;
$date02 = date("Y") ;
$yearthai02 = $date02+543 ;
?>
<?php
if($yearthai == $txtbudget01)
{
$txtbudget = $_POST['txtbudget'];
$txtmoney = $_POST['txtmoney'];
$sql ="insert into tbbudgetyear (
BudgetyearID,Budgetyear,Budgetyearmoney)values
('NULL','$txtbudget','$txtmoney')";
$result=mysql_query($sql,$conn);
echo "<script language='javascript'>alert('บันทึกข้อมูลเรียบร้อยแล้ว');</script>";
//echo "<meta http-equiv='refresh' content='0;url=selectlistbudget.php?year=$txtbudget' />";
}elseif($yearthai01 == $txtbudget01)
{
$txtbudget = $_POST['txtbudget'];
$txtmoney = $_POST['txtmoney'];
$sql ="insert into tbbudgetyear (
BudgetyearID,Budgetyear,Budgetyearmoney)values
('NULL','$txtbudget','$txtmoney')";
$result=mysql_query($sql,$conn);
echo "<script language='javascript'>alert('บันทึกข้อมูลเรียบร้อยแล้ว');</script>";
//echo "<meta http-equiv='refresh' content='0;url=selectlistbudget.php?year=$txtbudget' />";
}elseif($yearthai02 > $txtbudget01)
{
$txtbudget = $_POST['txtbudget'];
$txtmoney = $_POST['txtmoney'];
$sql ="insert into tbbudgetyear (
BudgetyearID,Budgetyear,Budgetyearmoney)values
('NULL','$txtbudget','$txtmoney')";
$result=mysql_query($sql,$conn);
echo "<script language='javascript'>alert('บันทึกข้อมูลเรียบร้อยแล้ว');</script>";
//echo "<meta http-equiv='refresh' content='0;url=selectlistbudget.php?year=$txtbudget' />";
}
else
{
echo "ปีงบประมาณนี้ผิดรูปแบบ" ;
}
?>
Tag : PHP, HTML/CSS, JavaScript, Ajax, jQuery
|
ประวัติการแก้ไข 2014-09-16 15:01:27 2014-09-16 15:03:07
|
 |
 |
 |
 |
Date :
2014-09-16 15:00:46 |
By :
nest12345 |
View :
716 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |