|
|
|
ขอสอบถามเรื่อง Search ข้อมูลอ่าครับ คำค้นหายไป หรือว่าใส่เงื่อนไขผิดอ่าครับ |
|
|
|
|
|
|
|
พอดีทำค้นหาข้อมูลอ่ะครับ ค้นหาได้แล้ว แต่ติดปัญหา คือ ว่าผมแสดงข้อมูลหน้าล่ะห้าฟิล พอกดหน้าสอง คำค้นหายไปอ่าครับพี่ๆ ขอบคุณครับ
Code (PHP)
<p> </p>
<form id="searchResearchYear" name="searchResearchYear" method="post" action="">
<p align="center" class="headtableTextTahoma11ptBold"><img src="img/BTTitleSearchRe.png" width="500" height="50" /></p>
<table width="700" border="0" align="center" cellpadding="3" cellspacing="2" class="TextboxBorderSoild">
<tr align="center">
<td width="96" class="headtableTextTahoma11ptBoldBG">ค้นหาจาก</td>
<td width="156" class="headtableTextTahoma11ptBoldBG"><span class="contenttableBG">
<select name="field" id="field">
<option value="" selected="selected">-------- กรุณาเลือก --------</option>
<option value="research_name">ชื่องานวิจัย</option>
<option value="research_year">ปีการศึกษา</option>
</select>
</span></td>
<td width="50" class="contenttableBG"><span class="headtableTextTahoma11ptBoldBG">คำค้น</span></td>
<td width="250" class="contenttableBG"><input name="keyword" type="text" id="keyword" size="35" /></td>
<td width="106" class="contenttableBG"><input name="search" type="submit" id="search" value="ค้นหา" />
<input name="cancel2" type="reset" id="cancel2" value="ยกเลิก" /></td>
</tr>
</table>
<div align="center">
<p>
<?php
$maxRows_research_query = 10;
$pageNum_research_query = 0;
if (isset($_GET['pageNum_research_query'])) {
$pageNum_research_query = $_GET['pageNum_research_query'];
}
$startRow_research_query = $pageNum_research_query * $maxRows_research_query;
mysql_select_db($database_connect, $connect);
$field = $_POST[field];
$_SESSION[field] = $field;
$key = $_POST[keyword];
$_SESSION[keyword] = $key;
if($_SESSION[field]=="" & $_SESSION[keyword]=="")
{
$query_research_query = "SELECT * FROM research";
$query_limit_research_query = sprintf("%s LIMIT %d, %d", $query_research_query, $startRow_research_query, $maxRows_research_query);
$research_query = mysql_query($query_limit_research_query, $connect) or die(mysql_error());
$row_research_query = mysql_fetch_assoc($research_query);
}
if($_SESSION[field]=="research_name" & $_SESSION[keyword]!="")
{
$query_research_query = "SELECT * FROM research where research_name like '%$_SESSION[keyword]%'";
$query_limit_research_query = sprintf("%s LIMIT %d, %d", $query_research_query, $startRow_research_query, $maxRows_research_query);
$research_query = mysql_query($query_limit_research_query, $connect) or die(mysql_error());
$row_research_query = mysql_fetch_assoc($research_query);
}
else if($_SESSION[field]=="research_year" & $_SESSION[keyword]!="")
{
$query_research_query = "SELECT * FROM research where research_year like '%$_SESSION[keyword]%' ";
$query_limit_research_query = sprintf("%s LIMIT %d, %d", $query_research_query, $startRow_research_query, $maxRows_research_query);
$research_query = mysql_query($query_limit_research_query, $connect) or die(mysql_error());
$row_research_query = mysql_fetch_assoc($research_query);
}
else
{
$query_research_query = "SELECT * FROM research";
$query_limit_research_query = sprintf("%s LIMIT %d, %d", $query_research_query, $startRow_research_query, $maxRows_research_query);
$research_query = mysql_query($query_limit_research_query, $connect) or die(mysql_error());
$row_research_query = mysql_fetch_assoc($research_query);
}
echo $query_research_query;
$nub = mysql_num_rows(mysql_query($query_research_query));
echo $nub;
if (isset($_GET['totalRows_research_query'])) {
$totalRows_research_query = $_GET['totalRows_research_query'];
} else {
$all_research_query = mysql_query($query_research_query);
$totalRows_research_query = mysql_num_rows($all_research_query);
}
$totalPages_research_query = ceil($totalRows_research_query/$maxRows_research_query)-1;
$queryString_research_query = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_research_query") == false &&
stristr($param, "totalRows_research_query") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_research_query = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_research_query = sprintf("&totalRows_research_query=%d%s", $totalRows_research_query, $queryString_research_query);
?>
</p>
<p> </p>
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#66CCFF"><div align="center"><strong>ชื่องานวิจัย</strong></div></td>
<td bgcolor="#66CCFF"><div align="center"><strong>ปีการศึีกษา</strong></div></td>
<td bgcolor="#66CCFF"><div align="center"><strong>คณะวิชาและผู้บริหาร</strong></div></td>
</tr>
<?php do {
?>
<tr>
<td bgcolor="#FFFFFF"><div align="center"><a href="/tcc_research_innovation/file_research/<?php echo $row_research_query['research_file']; ?>"><?php echo $row_research_query['research_name']; ?></a></div></td>
<td bgcolor="#FFFFFF"><div align="center"><?php echo $row_research_query['research_year']; ?></div></td>
<td bgcolor="#FFFFFF"><div align="center">
<? $query_faculty = "SELECT * FROM faculty_executives where faculty_executives_id =".$row_research_query['faculty_executives_id'];
$faculty_query = mysql_query($query_faculty, $connect) or die(mysql_error());
$row_faculty_query = mysql_fetch_assoc($faculty_query);
echo $row_faculty_query['faculty_executives_name'];
?>
</div></td>
</tr>
<?php } while ($row_research_query = mysql_fetch_assoc($research_query));?>
</table>
<p>
<?
$sum=ceil($nub/$maxRows_research_query);
$suma=0;
$last_pd=$nub-$maxRows_research_query;
echo "หน้า";
for($a=1;$a<=$sum;$a++)
{
?>
<a href='search_research.php?pageNum_research_query=<? echo "$suma"; ?>'><? echo "$a"; ?></a>
<? $suma=$suma+1;
}
$suma-=1;
?>
</p>
</div>
</form>
Tag : PHP, CakePHP
|
|
|
|
|
|
Date :
2011-10-14 21:27:25 |
By :
darkpee666 |
View :
786 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<form id="searchResearchYear" name="searchResearchYear" method="get" action="">
ลองใช้ get ดูนะ มันจะได้ส่งค่าไปทุกๆหน้า
|
|
|
|
|
Date :
2011-10-14 23:06:20 |
By :
onedan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ่าครับ ขอบคุณครับ ขอลองสักหน่อย ^ ^
|
|
|
|
|
Date :
2011-10-15 18:35:49 |
By :
darkpee666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ก็ยังไม่ได้อ่าครับ เหมือนคำค้่นมันหายไปอ่าครับ
|
|
|
|
|
Date :
2011-10-15 18:40:05 |
By :
darkpee666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ส่งแบบ get รับแบบ get ด้วยสิ
$_GET['']
หรือ
$_REQUEST['']
|
|
|
|
|
Date :
2011-10-16 21:20:47 |
By :
onedan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ่าครับ ขอบคุณครับ ต้องลองสักหน่อย
|
|
|
|
|
Date :
2011-10-17 19:50:42 |
By :
darkpee666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เย้ ขอบคุณครับได้แล้วครับ ขอบคุณมากครับ ^ ^
|
|
|
|
|
Date :
2011-10-18 11:19:08 |
By :
darkpee666 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|