|
|
|
สอบถามการทำหน้าค้นหาข้อมูลโดยให้ข้อมูลแสดงในหน้าเดียวกันกับหน้าป้อนคำค้นหา |
|
|
|
|
|
|
|
////////////////////////////////////////ไฟล์ search.php ไว้ป้อนคำค้นหา //////////////////////////
Code (PHP)
<?php
session_save_path("./session");
session_start();
header('Content-Type: text/html; charset=utf-8');
if(!isset($_SESSION['user'])){
?> <script language="javascript">
alert('กรุณาลงชื่อเข้าใช้');
window.location = 'login.php';
</script>
<?}else if(!($_SESSION['user'] == 'material_a')){
?> <script language="javascript">
alert('บัญชีผู้ใช้ของคุณไม่มีสิทธิ์เข้าถึงหน้านี้');
window.location = 'home.php';
</script>
<?}else{
?>
<html>
<title>ระบบวัสดุ - ค้นหารายการวัสดุ</title>
<link href="css/tooplate_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<center><table width = '100%' bgcolor = '#009440'><tr><td><h1><b><font color = 'yellow'><center>ระบบวัสดุ</font></b></h1></td></tr></table>
<table width = '100%' height ='1' bgcolor = 'yellow'><tr></tr></table></center>
<table width = '100%' height ='100%' border = '0' CELLSPACING='0'>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="add.php"><img src="images/add_button.gif" onmouseover="this.src='images/add_button2.gif'" onmouseout="this.src='images/add_button.gif'"></a></td><td rowspan = '9' valign = 'top'><font size = '6'><p><b>ค้นหารายการวัสดุ</b></p></font><br>
<form name = 'form1' method = 'post' action = 'search2.php' target = 'iframe'>
<table bgcolor = '#aff2f0'><tr><td align = 'right'><h3><b>ชื่อวัสดุ : </b></h3></td><td><input type='text' name = 'name' id = 'name' size = '50' placeholder = 'ทั้งหมด'><input name="h_name" type="hidden" id="h_name" value=""/></td></tr>
<tr><td align = 'right'><h3><b>ประเภทวัสดุ : </b></h3></td><td><select name = 'type'><option value =''>ทุกประเภท</option><option value ='T01'>วัสดุสำนักงาน</option><option value = 'T02'>วัสดุฝึก</option><option value = 'T03'>วัสดุงานบ้าน</option></td></tr>
<tr><td colspan = '2'><center><input type ='submit' value = 'ค้นหา'></center></td></tr>
</table></td></tr></form>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="search.php"><img src="images/search_button.gif" onmouseover="this.src='images/search_button2.gif'" onmouseout="this.src='images/search_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="return.php"><img src="images/return_button.gif" onmouseover="this.src='images/return_button2.gif'" onmouseout="this.src='images/return_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="out1.php"><img src="images/out1_button.gif" onmouseover="this.src='images/out1_button2.gif'" onmouseout="this.src='images/out1_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="out2.php"><img src="images/out2_button.gif" onmouseover="this.src='images/out2_button2.gif'" onmouseout="this.src='images/out2_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="out3.php"><img src="images/out3_button.gif" onmouseover="this.src='images/out3_button2.gif'" onmouseout="this.src='images/out3_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="out4.php"><img src="images/out4_button.gif" onmouseover="this.src='images/out4_button2.gif'" onmouseout="this.src='images/out4_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '53'><a href="logout.php" onclick="return confirm('คุณแน่ใจหรือไม่ที่จะออกจากระบบ?')"><img src="images/logout_button.gif" onmouseover="this.src='images/logout_button2.gif'" onmouseout="this.src='images/logout_button.gif'"></a></td></tr>
<tr><td bgcolor = '#009440' width = '180' height = '100%'></td></tr>
</table>
<iframe name='iframe' src='#' style="width:0;height:0;border:0px solid #fff;"></iframe>
<?}?>
<script language = 'javascript'>
function isNumber(evt) {
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
</script>
<script type="text/javascript" src="./jquery/autocomplete.js"></script>
<link rel="stylesheet" href="./css/autocomplete.css" type="text/css"/>
<script type="text/javascript">
function make_autocom(autoObj,showObj){
var mkAutoObj=autoObj;
var mkSerValObj=showObj;
new Autocomplete(mkAutoObj, function() {
this.setValue = function(id) {
document.getElementById(mkSerValObj).value = id;
}
if ( this.isModified )
this.setValue("");
if ( this.value.length < 1 && this.isNotClick )
return ;
return "auto_name.php?p=" +encodeURIComponent(this.value);
});
}
make_autocom("name","h_name");
</script>
</html>
//////////////////////////////////////////////////////////////////////////////////search2.php ส่งค่ามายังหน้านี้เพื่อquery///////////////////////////////////////////
<?php
session_save_path("./session");
session_start();
header('Content-Type: text/html; charset=utf-8');
$name = $_POST["name"];
$type = $_POST["type"];
require_once('connect.php');
mysql_query("SET NAMES UTF8",$connect);
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
if($name == '' && $type == ''){
$strQuery = "SELECT name,type_name,num,unit,price_c FROM material,type
WHERE type.type_material = material.type_material
group by name";
$result = mysql_query($strQuery);
while($row = mysql_fetch_assoc($result)){
echo $row['name'];
echo $row['type_name'];
echo $row['num'];
echo $row['unit'];
echo $row['price_c'];
}
}?>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax
|
|
|
|
|
|
Date :
2014-11-09 01:20:05 |
By :
axyz987 |
View :
677 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PHP MySQL Search Data Record (mysqli)
|
|
|
|
|
Date :
2014-11-09 07:55:32 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|