PHP Code Search ใช้งานไม่เกิดจากอะไรครับ ช่วยตรวจสอบให้หน่อยครับ
Code (PHP)
<?php
require ('connect.php');
session_start();
if($_SESSION['User_id'] == ""){
header("Content-type: text/html; charset=utf-8");
echo"<script language='JavaScript' >";
echo"alert('กรุณากรอกข้อมูลเพื่อเข้าสู่ระบบ');";
echo"</script>";
echo "<meta http-equiv='refresh' content='0;url=index.php' />";
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" href="bootstrap/css/footer.css">
<link rel="stylesheet" href="bootstrap/css/base.css">
<link rel="stylesheet" href="bootstrap/css/skeleton.css">
<link rel="stylesheet" href="bootstrap/css/layout.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap/css/bootstrap.css" rel="stylesheet"/>
<link type"text/css" rel="Stylesheet" href="bootstrap/css/bootstrap.css" />
<meta charset="UTF-8">
<title>Asset Management</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="col-md-12 column">
<h3></h3>
</div>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
Asset Management</h1>
</div>
<?php include("navbartop.php"); ?>
<div class="col-md-12 column">
<div class="form-group ">
<div class="form-inline">
<a title="Add Asset Information" href="addgadget.php">
<button type="button" class="btn btn-success">ADD Asset Information</button>
</a>
</div>
</div>
</div>
<form name="form1" method="post" action="Mainpage.php">
<table width="98%" >
<tr>
<td width="46%"><div align="right"><strong>
ค้นหา</strong> :
</div></td>
<td width="54%"><strong>
<select name="Search2" style="background: #CAF4F9">
<option value="Gadget_id" <? if($Search2=="Gadget_id"){ ?>selected<? }?>>รหัสทรัพย์สิน</option>
<option value="Brand" <? if($Search2=="Brand"){ ?>selected<? }?>>ชื่อคอมพิวเตอร์</option>
<option value="Gadget_user" <? if($Search2=="Gadget_user"){ ?>selected<? }?>>ผู้ใช้</option>
<option value="Serial" <? if($Search2=="Serial"){ ?>selected<? }?>>รหัสทรัพย์สินคอม</option>
</select>
</strong>
<input name="Search" type="text" size="20" style=" background:#CAF4F9" st value="<? echo $Search?>"onFocus="this.value = '';">
<input type="submit" name="submit" value="Search" title="ค้นหา"></tr>
</table>
</form>
<div class="col-md-12 column">
<h3></h3>
</div>
<?php
$strSQL = " SELECT * FROM tb_gadget,tb_department,tb_gadgettype,tb_brand,tb_cpu,tb_mb,tb_ram
where
tb_gadget.Gadgettype_id = tb_gadgettype.Gadgettype_id
AND
tb_gadget.Department_user = tb_department.Department_id
AND
tb_gadget.Brand_tb = tb_brand.Brand_id
AND
tb_gadget.cpu_tb = tb_cpu.cpu_id
AND
tb_gadget.mb_tb = tb_mb.mb_id
AND
tb_gadget.ram_tb = tb_ram.ram_id ORDER BY gadget_id";
$objQuery = mysql_query ($strSQL);
?>
<table class="table table-bordered table-hover">
<tbody>
<tr>
<td><table class="table table-bordered table-hover">
<thead>
<tr class="active">
<th><div align="center"><strong>No.</strong></div></th>
<th><div align="center"><strong>Asset ID</strong></div></th>
<th><div align="center"><strong>Monitor ID</strong></div></th>
<th><div align="center"><strong> User </strong></div></th>
<th><div align="center"><strong>Department</strong></div></th>
<th><div align="center"><strong>Type</strong></div></th>
<th><div align="center"><strong>ComputerName</strong></div></th>
<th><div align="center"><strong>Brand&<span id="result_box2" lang="en">Models</span></strong></div></th>
<th><div align="center"><strong>Location</strong></div></th>
<th><div align="center"><strong>DateOfPurchase</strong></div></th>
<th><div align="center"><strong>Details</strong></div></th>
<th><div align="center"><strong>View</strong></div></th>
</tr>
</thead>
<tbody>
<?php
$i = 1 ;
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><?php echo $i++;?><?php echo $objResult["Gadget_id"];?> </td>
<td><?php echo $objResult["Serial"];?></td>
<td><?php echo $objResult["Amount"];?></td>
<td><?php echo $objResult["Gadget_user"];?></td>
<td><?php echo $objResult["Department"];?></td>
<td><?php echo $objResult["Gadgettype"];?></td>
<td><?php echo $objResult["Brand"];?></td>
<td><?php echo $objResult["Brand_type"];?></td>
<td><?php echo $objResult["Unit"];?></td>
<td><?php echo $objResult["Date_purchase"];?></td>
<td><?php echo $objResult["Detail"];?></td>
<td border="0"><a href="viewgadget.php?view_id=<?php echo $objResult['Gadget_id'];?>">
<button type="button" class="btn btn btn-info"> <span class="glyphicon glyphicon-search"></span> </button>
</a></td>
</tr>
<?php }?>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php include("footer.php"); ?>
</div>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap-datepicker.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery || document.write("<script src='js/jquery-1.5.1.min.js'>\x3C/script>")</script>
<script src="js/app.js"></script>
</body>
</html>
Tag : PHP, MySQL, HTML/CSS, JavaScript
Date :
2014-12-24 10:47:29
By :
unicorn51
View :
940
Reply :
5
Query คุณผิดหรือเปล่าครับ
Date :
2014-12-24 11:10:30
By :
mr.win
Code (PHP)
<?
if($strSearch=="Y"){
$Qtotal = mysql_query("select * from tb_gadget Where ".$Search2." like '%".$Search."%' ");
}else{
$Qtotal = mysql_query("select * from tb_gadget");
}
$total = mysql_num_rows($Qtotal);
if($strSearch=="Y"){
$Query = mysql_query("select * from tb_gadget Where ".$Search2." like '%".$Search."%' order by Gadget_id DESC LIMIT $start,$limit");
}else{
$Query= mysql_query("select * from tb_gadget order by Gadget_id DESC LIMIT $start,$limit");
?>
เพิ่มcodeนี้เข้าไปแล้วติดerrorครับ Parse error: syntax error, unexpected $end in C:\AppServ\www\as\Mainpage.php on line 182
ประวัติการแก้ไข 2014-12-24 11:21:43 2014-12-24 11:22:00 2014-12-24 11:22:23
Date :
2014-12-24 11:20:46
By :
unicorn51
ลองสำรวจ เครื่องหมายปีกกา } ดูครับว่าปิดครบหรือยัง?
Date :
2014-12-24 12:10:43
By :
Manussawin
Code (PHP)
<?php
require ('connect.php');
session_start();
if($_SESSION['User_id'] == ""){
header("Content-type: text/html; charset=utf-8");
echo"<script language='JavaScript' >";
echo"alert('กรุณากรอกข้อมูลเพื่อเข้าสู่ระบบ');";
echo"</script>";
echo "<meta http-equiv='refresh' content='0;url=index.php' />";
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" href="bootstrap/css/footer.css">
<link rel="stylesheet" href="bootstrap/css/base.css">
<link rel="stylesheet" href="bootstrap/css/skeleton.css">
<link rel="stylesheet" href="bootstrap/css/layout.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap/css/bootstrap.css" rel="stylesheet"/>
<link type"text/css" rel="Stylesheet" href="bootstrap/css/bootstrap.css" />
<meta charset="UTF-8">
<title>Asset Management</title>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
</head>
<body>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="col-md-12 column">
<h3></h3>
</div>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
<div class="page-header">
<h1>
Asset Management</h1>
</div>
<?php include("navbartop.php"); ?>
<div class="col-md-12 column">
<div class="form-group ">
<div class="form-inline">
<a title="Add Asset Information" href="addgadget.php">
<button type="button" class="btn btn-success">ADD Asset Information</button>
</a>
</div>
</div>
</div>
<form name="form1" method="post" action="Mainpage.php">
<table width="98%" >
<tr>
<td width="46%"><div align="right"><strong>
ค้นหา</strong> :
</div></td>
<td width="54%"><strong>
<select name="Search2" style="background: #CAF4F9">
<option value="Gadget_id" <? if($Search2=="Gadget_id"){ ?>selected<? }?>>รหัสทรัพย์สิน</option>
<option value="Brand" <? if($Search2=="Brand"){ ?>selected<? }?>>ชื่อคอมพิวเตอร์</option>
<option value="Gadget_user" <? if($Search2=="Gadget_user"){ ?>selected<? }?>>ผู้ใช้</option>
<option value="Serial" <? if($Search2=="Serial"){ ?>selected<? }?>>รหัสทรัพย์สินคอม</option>
</select>
</strong>
<input name="Search" type="text" size="20" style=" background:#CAF4F9" st value="<? echo $Search?>"onFocus="this.value = '';">
<input type="submit" name="submit" value="Search" title="ค้นหา"></tr>
</table>
</form>
<div class="col-md-12 column">
<h3></h3>
</div>
<?
if($strSearch=="Y"){
$Qtotal = mysql_query("select * from tb_gadget Where ".$Search2." like '%".$Search."%' ");
}else{
$Qtotal = mysql_query("select * from tb_gadget");
}
$total = mysql_num_rows($Qtotal);
if($strSearch=="Y"){
$Query = mysql_query("select * from tb_gadget Where ".$Search2." like '%".$Search."%' order by Gadget_id DESC LIMIT $start,$limit");
}else{
$Query= mysql_query("select * from tb_gadget order by Gadget_id DESC LIMIT $start,$limit");
}
?>
<?php
$strSQL = " SELECT * FROM tb_gadget,tb_department,tb_gadgettype,tb_brand,tb_cpu,tb_mb,tb_ram
where
tb_gadget.Gadgettype_id = tb_gadgettype.Gadgettype_id
AND
tb_gadget.Department_user = tb_department.Department_id
AND
tb_gadget.Brand_tb = tb_brand.Brand_id
AND
tb_gadget.cpu_tb = tb_cpu.cpu_id
AND
tb_gadget.mb_tb = tb_mb.mb_id
AND
tb_gadget.ram_tb = tb_ram.ram_id ORDER BY gadget_id";
$objQuery = mysql_query ($strSQL);
?>
<table class="table table-bordered table-hover">
<tbody>
<tr>
<td><table class="table table-bordered table-hover">
<thead>
<tr class="active">
<th><div align="center"><strong>No.</strong></div></th>
<th><div align="center"><strong>Asset ID</strong></div></th>
<th><div align="center"><strong>Monitor ID</strong></div></th>
<th><div align="center"><strong> User </strong></div></th>
<th><div align="center"><strong>Department</strong></div></th>
<th><div align="center"><strong>Type</strong></div></th>
<th><div align="center"><strong>ComputerName</strong></div></th>
<th><div align="center"><strong>Brand&<span id="result_box2" lang="en">Models</span></strong></div></th>
<th><div align="center"><strong>Location</strong></div></th>
<th><div align="center"><strong>DateOfPurchase</strong></div></th>
<th><div align="center"><strong>Details</strong></div></th>
<th><div align="center"><strong>View</strong></div></th>
</tr>
</thead>
<tbody>
<?php
$i = 1 ;
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><?php echo $i++;?><?php echo $objResult["Gadget_id"];?> </td>
<td><?php echo $objResult["Serial"];?></td>
<td><?php echo $objResult["Amount"];?></td>
<td><?php echo $objResult["Gadget_user"];?></td>
<td><?php echo $objResult["Department"];?></td>
<td><?php echo $objResult["Gadgettype"];?></td>
<td><?php echo $objResult["Brand"];?></td>
<td><?php echo $objResult["Brand_type"];?></td>
<td><?php echo $objResult["Unit"];?></td>
<td><?php echo $objResult["Date_purchase"];?></td>
<td><?php echo $objResult["Detail"];?></td>
<td border="0"><a href="viewgadget.php?view_id=<?php echo $objResult['Gadget_id'];?>">
<button type="button" class="btn btn btn-info"> <span class="glyphicon glyphicon-search"></span> </button>
</a></td>
</tr>
<?php }?>
</tbody>
</table></td>
</tr>
</tbody>
</table>
</div>
</div>
<?php include("footer.php"); ?>
</div>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap-datepicker.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery || document.write("<script src='js/jquery-1.5.1.min.js'>\x3C/script>")</script>
<script src="js/app.js"></script>
</body>
</html>
ขอบคุณครับ TC Admin , SiamHTTP
ได้ตรวจทำตามคำแนะนำบ้างแล้วครับบ้างแล้วครับ แต่ยังไม่สำเร็จครับ
Date :
2014-12-24 14:19:53
By :
unicorn51
ลองแก้ไขอยู่ก็ยังไม่ได้เลยครับ ><"
Date :
2014-12-24 18:12:21
By :
unicorn51
Load balance : Server 04