|
|
|
รบกวนนิครับ เรื่อง ใส่ข้อมูล 2 อันใน TextBox แล้วทำงานใสส่วนที่เลือกครับ |
|
|
|
|
|
|
|
รบกวนหน่อยครับ พอดีทำตัว Search มา 2 Textbox ครับ แต่จะให้ค้นหาแค่ 2 อัน ทำไงดีครับ
Code (PHP)
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$strKeyword = null;
if(isset($_POST["txtKeyword"]))
{
$strKeyword = $_POST["txtKeyword"];
}
?>
<link rel="stylesheet" type="text/css" media="all" href="calenda/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="calenda/jsDatePick.min.1.3.js"></script>
<script type="text/javascript">
function getDateBG(){
new JsDatePick({
useMode:2,
target:"txtdocdate",
dateFormat:"%d-%m-%Y"
});
};
</script>
<script type="text/javascript">
function getDateED(){
new JsDatePick({
useMode:2,
target:"txtcreatdate",
dateFormat:"%d-%m-%Y"
});
};
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Sodick (Thailand)</title>
<link rel="stylesheet" href="css/style.css">
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<body bgcolor="#FFFFFF">
<center>
<th width="1073" valign="top" scope="col"><table width="876" border="0" align="top">
<tr>
<th width="100%" height="908" valign="top" scope="col"><table width="41%" border="0" align="top">
<tr>
<th width="100%" height="61" scope="col"><div align="center"><img src="Bonton/website2.png" width="892" height="114" usemap="#Map2" border="0" /></div></th>
</tr>
</table>
<table width="98%" height="25" border="0" align="center">
<tr>
<td width="100%" height="21" valign="top" scope="col"><marquee scrollamount="4" onmouseover=this.stop() onmouseout=this.start() >
</table>
<table width="866" height="121" border="0">
<tr>
<th width="314" height="117" valign="top" scope="col"><div align="right"><img src="img/website.png" width="313" height="115" /></div></th>
<th width="542" align="top" scope="col"><img src="img/Test.gif" width="545" height="114" align="top"></th> </tr> </table>
<table width="836" height="564" border="0" align="left"background="img/website15.png">
<tr>
<th height="356" colspan="2" scope="col">
<table width="847" height="246" border="0">
<tr>
<td width="841" height="242" align="center" valign="top"><table width="581" border="0">
</table>
<p> </p>
<p> </p>
<p> </p>
<table width="602" border="0">
<tr>
<td width="596">
<form name="frmSearch" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<table width="496" border="0">
</table>
</form>
<?php
include '..//connect.php';
$stmt = "SELECT * FROM admin WHERE docdate LIKE '%".$strKeyword."%' or name LIKE '%".$strKeyword."%'or refno LIKE '%".$strKeyword."%' ";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$query = sqlsrv_query( $conn, $stmt , $params, $options );
$num_rows = sqlsrv_num_rows($query);
$per_page = 8; // Per Page
$page = 1;
if(isset($_GET["Page"]))
{
$page = $_GET["Page"];
}
$prev_page = $page-1;
$next_page = $page+1;
$row_start = (($per_page*$page)-$per_page);
if($num_rows<=$per_page)
{
$num_pages =1;
}
else if(($num_rows % $per_page)==0)
{
$num_pages =($num_rows/$per_page) ;
}
else
{
$num_pages =($num_rows/$per_page)+1;
$num_pages = (int)$num_pages;
}
$row_end = $per_page * $page;
if($row_end > $num_rows)
{
$row_end = $num_rows;
}
$stmt = " SELECT c.* FROM (
SELECT ROW_NUMBER() OVER(ORDER BY id desc) AS RowID,* FROM admin WHERE docdate LIKE '%".$strKeyword."%' or name LIKE '%".$strKeyword."%'or refno LIKE '%".$strKeyword."%'
) AS c
WHERE c.RowID > $row_start AND c.RowID <= $row_end
";
$query = sqlsrv_query( $conn, $stmt );
?>
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$strKeyword = null;
if(isset($_POST["txtKeyword"]))
{
$strKeyword = $_POST["txtKeyword"];
}
?>
</p>
<table width="514" border="0">
<tr>
<th width="134"> <div align="center"><font size="2">Ref. No</font></div></th>
<th width="71"> <div align="center"><font size="2">Date</font></div></th>
<th width="165"> <div align="center"><font size="2">Name</font></div></th>
<th width="38"> <div align="center"><font size="2">Add</font></div></th>
<th width="31"> <div align="center"><font size="2">Edit</font></div></th>
<th width="49"> <div align="center"><font size="2">Delete</font></div></th>
</tr>
<?php
while($result = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC))
{
?>
<tr>
<td height="28"><div align="center"><a href="../WEB/Circular/<?php echo $result["refno"];?>"><font color="#0066CC" size="2"><?php echo $result["refno"];?></font></a></div></td>
<td align="center"><font size="2"><?php echo $result["docdate"];?></font></div></td>
<td align="center"><font size="2"><?php echo $result["name"];?></font></td>
<td align="center"><a href="add.php?id=<?php echo $result["id"];?>"><img src="img/add.jpg" width="21" height="24" border="0"/></a></td>
<td align="center"><a href="edit2.php?id=<?php echo $result["id"];?>"><img src="img/edit.jpg" width="17" height="16" border="0"/></a></td>
<td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='delete.php?id=<?php echo $result["id"];?>';}"><img src="img/delete.jpg" width="17" height="16" border="0" /></a></td>
</tr>
<?php
}
?>
</table>
</tr>
</table>
<form action="save.php" name="frmAdd" method="post">
</form>
<table width="859" border="0">
<tr>
<td width="469" height="93"> </td>
<td width="380" align="center"><form name="frmSearch" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<table width="240" border="0">
<tr>
<th width="407"><p>
</p>
<p> Year
<input name="txtKeyword" type="text" id="txtKeyword" value="<?php echo $strKeyword;?>">
</p>
<p>Manth <input name="txtKeyword" type="text" id="txtKeyword" value="<?php echo $strKeyword;?>">
</p>
<br>
<p>
<input name="Submit" type="submit" value="Search">
</p></th>
</tr>
</table>
</form></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<p><font color="red">Total <?php echo $num_rows;?> Record : <?php echo $num_pages;?> Page :
<?php
if($prev_page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$prev_page'><< Back</a> ";
}
for($i=1; $i<=$num_pages; $i++){
if($i != $page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($page!=$num_pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$next_page'>Next>></a> ";
}
?>
</font>
<?php
sqlsrv_close($conn);
?>
</p></th>
</tr>
<tr>
<th width="280" height="35" align="left" scope="col"></div></th>
<th width="546" scope="col"> </th>
</tr>
</table>
</tr>
</table>
</head>
</map>
</body>
</html>
Tag : PHP, Ms SQL Server 2008
|
|
|
|
|
|
Date :
2016-06-03 09:25:02 |
By :
pissanu8970 |
View :
781 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wไม่มีใครให้ข้อมูลเลยหรอครับ รออยู่ครับ
|
|
|
|
|
Date :
2016-06-06 08:03:19 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อธิบายแล้วยัง งง ๆ กับคำถามครับ
|
|
|
|
|
Date :
2016-06-06 11:03:30 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือว่า เวลาเราใส่ ข้อมูล Texbox ที่ 1 เช่น 2016 คือ (ปี) Texbox ที่ 2 ใส่ 05 คือ (เดือน) เสร็จแล้วก็จะค้นให้แค่ เดือน 5 ปี 2016 ประมาณนี้นะครับ
|
|
|
|
|
Date :
2016-06-06 13:36:07 |
By :
pissanu8970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (SQL)
SELECT * FROM Yourtable WHERE MONTH(Yourfield) = 5 AND YEAR(Yourfield) = 2016
ลองดูครับผมก็เดาเอาไม่ค่อยเก่ง
|
ประวัติการแก้ไข 2016-06-06 14:19:48
|
|
|
|
Date :
2016-06-06 14:18:56 |
By :
newalway |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|