|
|
|
ขอรบกวนสอบถามปัญหาครับ แบ่งหน้าได้ แต่ค้นหาใช้ไม่ได้ครับ |
|
|
|
|
|
|
|
ก่อนหน้านี้ค้นหาใช้ได้ครับ แต่พอใส่แบ่งหน้าเข้าไปก็ค้นหาไม่ได้ครับ
ผมลองแก้ไขแล้วแต่ก็ยังไม่ได้ครับ ไม่ทราบว่าใส่อะไรผิดไป เรียนท่านผู้รู้ชี้แนะหน่อยครับ
มือใหม่ครับผิดพลาดประการใดขอโทษด้วยครับ
ขอบคุณครับ
Code (PHP)
<?php ob_start(); ?>
<?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();
}
if ($_SESSION['Usertype_id'] != "1") {
//echo "This page for Admin only!";
echo "<meta http-equiv='refresh' content='0;url=logout.php'>";
exit();
}
$strSQL = "SELECT * FROM tb_user WHERE User_id = '" . $_SESSION['User_id'] . "' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<!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">
<div class="container">
<title>Help Desk Management</title>
</head>
<style type="text/css">
div#mylayout_1{
display:block;
width:300px;
/*border:1px solid #09C;
background-color:#CFC;*/
word-wrap:break-word;
}
</style>
<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="panel-title">
<h1><a href="helpdesk_add.php"><img src="img/branner.png" title="Open Ticket Click Here" width="533" height="115"></a></h1>
</div>
<?php include ("navbartop.php"); ?>
<form name="frmSearch" method="GET" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<?php
$strSQL = " SELECT * FROM tb_gadget,tb_priority,tb_issue,tb_status
where
tb_gadget.Gadget_id
AND
tb_gadget.priority_tb = tb_priority.priority_id
AND
tb_gadget.issue_tb = tb_issue.issue_id
AND
tb_gadget.status_tb = tb_status.status_id";
if (isset($_GET['ddlSelect'])!= "" and $_GET["txtKeyword"] != '')
{
$strSQL .= " AND (".$_GET["ddlSelect"]." LIKE '%".$_GET["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL .=" ORDER BY Gadget_id DESC") or die ("Error Query [".$strSQL."]");
?>
<?php
require ('connect.php');
$strSQL = " SELECT * FROM tb_gadget,tb_priority,tb_issue,tb_status
where
tb_gadget.Gadget_id
AND
tb_gadget.priority_tb = tb_priority.priority_id
AND
tb_gadget.issue_tb = tb_issue.issue_id
AND
tb_gadget.status_tb = tb_status.status_id";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 2; // Per Page
$Page = isset($_GET['Page']) ? $_GET['Page'] : 1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_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;
}
$strSQL .=" order by Gadget_id DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="Auto" border="1">
<tr>
<th height="50"> <span class="col-sm-0"> </span>
<span class="col-sm-3">
<select style="color:#3399FF" class="form-control" name="ddlSelect" id="ddlSelect" title="Click Select Item">
<option value="Gadget_id" <?if($_GET["ddlSelect"]=="Gadget_id"){echo"selected";}?>TICKET_ID</option>
<option value="ticket_date" <?if($_GET["ddlSelect"]=="ticket_date"){echo"selected";}?>TICKET_DATE</option>
<option value="department_users" <?if($_GET["ddlSelect"]=="department_users"){echo"selected";}?>DEPARTMENT</option>
<option value="priority_type" <?if($_GET["ddlSelect"]=="priority_type"){echo"selected";}?>PRIORITY</option>
<option value="issue_type" <?if($_GET["ddlSelect"]=="issue_type"){echo"selected";}?>ISSUE</option>
<option value="name_user" <?if($_GET["ddlSelect"]=="name_user"){echo"selected";}?>NAME</option>
</select>
</span><span class="col-sm-3">
<input style="color:#3399FF" name="txtKeyword" type="text" placeholder="Search" id="txtKeyword"onFocus="this.value = ''" title="Please Fill Search Message">
</span><span class="col-sm-1">
<button type="submit" title="Click Search" class="btn btn-primary"><span class="glyphicon glyphicon-search">Search</span> </button>
</span></th>
</tr>
</table>
<table width="140%" class="table table-hover">
<span class="label label-default" title="ยังไม่กำหนด">Undefined</span>
<span class="label label-info" title="รอดำเนินการ">Waiting</span>
<span class="label label-success" title="กำลังดำเนินการ">On Process</span>
<span class="label label-warning" title="ปิดงานระหว่างกาล">Closed-Interim</span>
<span class="label label-danger" title="ปิดงานระยะยาว">Closed-Longterm</span>
<span class="label label-primary" title="ส่งไปยังผู้จัดจำหน่าย">Sent To Supplier</span>
<thead>
<th width="9%"><div align="center"><strong>Ticket ID</strong></div></th>
<th width="5%"><div align="center"><strong>DATE </strong></div></th>
<th width="9%"><div align="center"><strong>PRIORITY</strong></div></th>
<th width="9%" align="center"><div align="center"><strong>ISSUE</strong></div></th>
<th width="28%"><div align="center"><strong>QUESTION</strong></div></th>
<th width="9%"><div align="center"><strong>DEPARTMENT</strong></div></th>
<th width="10%"><div align="center"><strong>NAME</strong></div></th>
<th width="7%" align="center"><div align="center"><strong>STATUS</strong></div></th>
<th width="9%" align="center" valign="middle"><div align="center"><strong>MANAGE</strong></div></th>
</tr>
</thead>
<tbody>
<?php
while ($objResult = mysql_fetch_array($objQuery)) {
?>
<tr>
<td height="42"><span class="label <?php echo $objResult["status_code"];?>">T<?php echo $objResult["ticket_date"];?>.<?php echo $objResult["Gadget_id"]; ?></span></td>
<td> <?php echo $objResult["date_time"]; ?></td>
<td> <?php echo $objResult["priority_type"]; ?></td>
<td> <?php echo $objResult["issue_type"]; ?></td>
<td><div id="mylayout_1"><?php echo $objResult["user_question"]; ?></div></td>
<td><?php echo $objResult["department_users"]; ?></td>
<td><?php echo $objResult["name_user"]; ?></td>
<td><span class="label <?php echo $objResult["status_code"];?>"> <?php echo $objResult["status_type"]; ?></td>
<td><a href="helpdesk_view.php?view_id=<?php echo $objResult['Gadget_id']; ?>">
<button type="button" class="btn btn btn-primary" title="Open Ticket"> <span class="glyphicon glyphicon-folder-open"></span> </button>
<a href="helpdesk_edit.php?edit_id=<?php echo $objResult['Gadget_id'];?> ">
<button type="button" class="btn btn btn-info" title="Manage Ticket"> <span class="glyphicon glyphicon-cog"></span> </button>
</a></td>
</tr>
<?php
}
?>
</table>
<br>
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> ";
}
mysql_close($objConnect);
?>
</tbody>
</table>
<meta http-equiv="refresh" content="60;url=Mainpage.php">
<?php include ("footer.php"); ?>
<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
|
ประวัติการแก้ไข 2015-08-19 00:07:00
|
|
|
|
|
Date :
2015-08-19 00:02:56 |
By :
unicorn51 |
View :
942 |
Reply :
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอคำอธิบายเพิ่มเติมครับ ผมต้องนำไปเพิ่มเติมส่วนไหนครับ
Notice: Undefined variable: Num_Rows in C:\xampp\htdocs\helpdesk\Mainpage.php on line 92
Total
Notice: Undefined variable: Num_Rows in C:\xampp\htdocs\helpdesk\Mainpage.php on line 173
Record : 1 Page : 1
ขอบคุณครับ
Code (PHP)
<?php ob_start(); ?>
<?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();
}
if ($_SESSION['Usertype_id'] != "1") {
//echo "This page for Admin only!";
echo "<meta http-equiv='refresh' content='0;url=logout.php'>";
exit();
}
$strSQL = "SELECT * FROM tb_user WHERE User_id = '" . $_SESSION['User_id'] . "' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<!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">
<div class="container">
<title>Help Desk Management</title>
</head>
<style type="text/css">
div#mylayout_1{
display:block;
width:300px;
/*border:1px solid #09C;
background-color:#CFC;*/
word-wrap:break-word;
}
</style>
<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="panel-title">
<h1><a href="helpdesk_add.php"><img src="img/branner.png" title="Open Ticket Click Here" width="533" height="115"></a></h1>
</div>
<?php include ("navbartop.php"); ?>
<form name="frmSearch" method="GET" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<?php
$strSQL = " SELECT * FROM tb_gadget,tb_priority,tb_issue,tb_status
where
tb_gadget.Gadget_id
AND
tb_gadget.priority_tb = tb_priority.priority_id
AND
tb_gadget.issue_tb = tb_issue.issue_id
AND
tb_gadget.status_tb = tb_status.status_id";
if (isset($_GET['ddlSelect'])!= "" and $_GET["txtKeyword"] != '')
{
$strSQL .= " AND (".$_GET["ddlSelect"]." LIKE '%".$_GET["txtKeyword"]."%' ) ";
}
$Per_Page = 2; // Per Page
$Page = isset($_GET['Page']) ? $_GET['Page'] : 1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_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;
}
$strSQL .=" order by Gadget_id DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="Auto" border="1">
<tr>
<th height="50"> <span class="col-sm-0"> </span>
<span class="col-sm-3">
<select style="color:#3399FF" class="form-control" name="ddlSelect" id="ddlSelect" title="Click Select Item">
<option value="Gadget_id" <?if($_GET["ddlSelect"]=="Gadget_id"){echo"selected";}?>TICKET_ID</option>
<option value="ticket_date" <?if($_GET["ddlSelect"]=="ticket_date"){echo"selected";}?>TICKET_DATE</option>
<option value="department_users" <?if($_GET["ddlSelect"]=="department_users"){echo"selected";}?>DEPARTMENT</option>
<option value="priority_type" <?if($_GET["ddlSelect"]=="priority_type"){echo"selected";}?>PRIORITY</option>
<option value="issue_type" <?if($_GET["ddlSelect"]=="issue_type"){echo"selected";}?>ISSUE</option>
<option value="name_user" <?if($_GET["ddlSelect"]=="name_user"){echo"selected";}?>NAME</option>
</select>
</span><span class="col-sm-3">
<input style="color:#3399FF" name="txtKeyword" type="text" placeholder="Search" id="txtKeyword"onFocus="this.value = ''" title="Please Fill Search Message">
</span><span class="col-sm-1">
<button type="submit" title="Click Search" class="btn btn-primary"><span class="glyphicon glyphicon-search">Search</span> </button>
</span></th>
</tr>
</table>
<table width="140%" class="table table-hover">
<span class="label label-default" title="ยังไม่กำหนด">Undefined</span>
<span class="label label-info" title="รอดำเนินการ">Waiting</span>
<span class="label label-success" title="กำลังดำเนินการ">On Process</span>
<span class="label label-warning" title="ปิดงานระหว่างกาล">Closed-Interim</span>
<span class="label label-danger" title="ปิดงานระยะยาว">Closed-Longterm</span>
<span class="label label-primary" title="ส่งไปยังผู้จัดจำหน่าย">Sent To Supplier</span>
<thead>
<th width="9%"><div align="center"><strong>Ticket ID</strong></div></th>
<th width="5%"><div align="center"><strong>DATE </strong></div></th>
<th width="9%"><div align="center"><strong>PRIORITY</strong></div></th>
<th width="9%" align="center"><div align="center"><strong>ISSUE</strong></div></th>
<th width="28%"><div align="center"><strong>QUESTION</strong></div></th>
<th width="9%"><div align="center"><strong>DEPARTMENT</strong></div></th>
<th width="10%"><div align="center"><strong>NAME</strong></div></th>
<th width="7%" align="center"><div align="center"><strong>STATUS</strong></div></th>
<th width="9%" align="center" valign="middle"><div align="center"><strong>MANAGE</strong></div></th>
</tr>
</thead>
<tbody>
<?php
while ($objResult = mysql_fetch_array($objQuery)) {
?>
<tr>
<td height="42"><span class="label <?php echo $objResult["status_code"];?>">T<?php echo $objResult["ticket_date"];?>.<?php echo $objResult["Gadget_id"]; ?></span></td>
<td> <?php echo $objResult["date_time"]; ?></td>
<td> <?php echo $objResult["priority_type"]; ?></td>
<td> <?php echo $objResult["issue_type"]; ?></td>
<td><div id="mylayout_1"><?php echo $objResult["user_question"]; ?></div></td>
<td><?php echo $objResult["department_users"]; ?></td>
<td><?php echo $objResult["name_user"]; ?></td>
<td><span class="label <?php echo $objResult["status_code"];?>"> <?php echo $objResult["status_type"]; ?></td>
<td><a href="helpdesk_view.php?view_id=<?php echo $objResult['Gadget_id']; ?>">
<button type="button" class="btn btn btn-primary" title="Open Ticket"> <span class="glyphicon glyphicon-folder-open"></span> </button>
<a href="helpdesk_edit.php?edit_id=<?php echo $objResult['Gadget_id'];?> ">
<button type="button" class="btn btn btn-info" title="Manage Ticket"> <span class="glyphicon glyphicon-cog"></span> </button>
</a></td>
</tr>
<?php
}
?>
</table>
<br>
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> ";
}
mysql_close($objConnect);
?>
</tbody>
</table>
<meta http-equiv="refresh" content="60;url=Mainpage.php">
<?php include ("footer.php"); ?>
<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>
|
ประวัติการแก้ไข 2015-08-19 21:56:03
|
|
|
|
Date :
2015-08-19 20:41:18 |
By :
unicorn51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองแก้ไขแล้วครับก็ยังไม่ได้ครับ T-T
|
|
|
|
|
Date :
2015-08-20 11:34:29 |
By :
unicorn51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวนท่านผู้รู้ชี้ทางเพิ่มเติมทีครับ
ขอบคุณครับ
|
|
|
|
|
Date :
2015-08-21 02:59:32 |
By :
unicorn51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
092. if($Num_Rows<=$Per_Page)
สีแดงยังไม่ได้ถูกกำหนดไว้ครับ
Code (PHP)
// กำหนด ชื่อตาราง และ where clause สำหรับการเรียกใช้หลายครั้ง
$tb_where = "FROM tb_gadget,tb_priority,tb_issue,tb_status
where tb_gadget.Gadget_id
AND tb_gadget.priority_tb = tb_priority.priority_id
AND tb_gadget.issue_tb = tb_issue.issue_id
AND tb_gadget.status_tb = tb_status.status_id";
if (isset($_GET['ddlSelect'])!= "" and $_GET["txtKeyword"] != ''){
$tb_where .= " AND (".$_GET["ddlSelect"]." LIKE '%".$_GET["txtKeyword"]."%' ) ";
}
$sql_for_num = 'SELSECT count(*) ' . $tb_where; // เรียกใช้ครั้งที่ 1 สำหรับ $tb_where หาจำนวน row
$rs_for_num=mysql_query($sql_for_num);
$ro_for_num = mysql_fetch_row($rs_for_num);
$Num_Rows = $ro_for_num[0];
$sql = 'SELECT * ' . $tb_where; เรียกใช้ครั้งที่ 2 หาข้อมูลที่ต้องการ
.....
.....
|
|
|
|
|
Date :
2015-08-21 05:32:56 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณท่าน TC Admin , NewbieXYZ ผมทำตามคำแนะนำของแต่ละท่าน ตอนนี้ทำได้ทั้งหมดแล้วครับ
ขอบคุณครับ^^
|
ประวัติการแก้ไข 2015-08-21 23:42:40
|
|
|
|
Date :
2015-08-21 23:12:26 |
By :
unicorn51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2015-08-23 09:03:08 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|