รบกวนเรื่องการดึง Status ครับ คือต้องการ ที่ จะให้หน้าจด โชว์ เฉพาะ Status ที่ เป็น 1 อย่างเดียวนะครับ ควารเพิ่มตรงไหนครับ
คือต้องการ ที่ จะให้หน้าจด โชว์ เฉพาะ Status ที่ เป็น 1 อย่างเดียวนะครับ ควารเพิ่มตรงไหนครับ
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></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="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="849" height="550" border="0" align="left"background="img/website15.png">
<tr>
<th height="356" colspan="2" scope="col">
<table width="864" height="246" border="0">
<tr>
<td width="858" height="242" align="center" valign="top"><table width="581" border="0">
</table>
<table width="701" border="0" align="right">
<tr>
<td width="695">
<form name="frmSearch" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<table width="496" border="0">
</table>
</form>
<?php
include '..//admin/connect.php';
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true,"CharacterSet" => 'UTF-8');
$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 = 10; // 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> <p align="right"><font size="2"></p></font>
<table width="679" border="0" >
<tr>
<th width="160" height="48"> </th>
<th width="104"> <div align="center"></div></th>
<th width="224"> <div align="center"></div></th>
<th width="66"> <div align="center"></div></th>
<th width="70"> <div align="center"><a href="add.php?id=<?php echo $result["id"];?>"><img src="img/add.jpg" width="41" height="36" border="0"/></a></div></th>
</tr>
<tr>
<th width="160"> <div align="center"><font size="2">Ref. No</font></div></th>
<th width="104"> <div align="center"><font size="2">Date</font></div></th>
<th width="224"> <div align="center"><font size="2">Name</font></div></th>
<th width="50"> <div align="center"><font size="2">Edit</font></div></th>
<th width="70"> <div align="center"><font size="2">Delete</font></div></th>
</tr>
<?php
while($result = sqlsrv_fetch_array($query,SQLSRV_FETCH_ASSOC))
{
?>
<tr>
<td height="18"><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="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">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p><br>
</p>
<table width="863" border="0">
<tr>
<td width="469" height="121"><p> </p>
<p> </p></td>
<td width="384" align="center"><form name="frmSearch" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
<table width="240" border="0">
<tr>
<th width="407" height="117">
<p> </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><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="292" height="16" align="left" scope="col"></div></th>
<th width="547" scope="col"> </th>
</tr>
</table>
</tr>
</table>
</head>
</map>
</body>
</html>
Tag : PHP, Ms SQL Server 2008
Date :
2016-06-07 14:02:44
By :
pissanu8970
View :
917
Reply :
7
Code (PHP)
WHERE (docdate LIKE '%".$strKeyword."%' OR name LIKE '%".$strKeyword."%' OR refno LIKE '%".$strKeyword."%') AND status = 1"
Date :
2016-06-08 13:44:10
By :
fossil31
ขอบคุณมากๆๆ เลยครับ
Date :
2016-06-08 14:14:11
By :
pissanu8970
ไม่จบอ่ะครับ เวลา Delete แล้ว update เปลี่ยน status เป้น 2 แต่พอกลับมาหน้าหลักก็โชว์อีกอ่ะครับ
Date :
2016-06-08 14:17:40
By :
pissanu8970
น่าจะ update ไม่สำเร็จ
echo sql_update แล้วเอาไป run->phpmyadmin ดูครับ
Date :
2016-06-08 14:29:08
By :
fossil31
อัเดทผ่านครับ status เปลี่ยนเป้น 2 แต่หน้าจอยังเลือกมาใช้อีก ทั้งๆที่ใส่ ให้เลือก 1 นะครับ
Date :
2016-06-08 14:32:04
By :
pissanu8970
ลองแก้ $stmt จุดที่ 2
Code (PHP)
$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."%') AND status = 1) AS c WHERE c.RowID > $row_start AND c.RowID <= $row_end";
Date :
2016-06-08 15:02:12
By :
fossil31
ใช่ละครับ ขอบคุณมากๆๆเลยครับ
Date :
2016-06-09 08:37:56
By :
pissanu8970
Load balance : Server 02