|
 |
|
พี่ครับ โค้ดที่ผมใช้ตอนแรกก็ใช่ได้แต่ทำไมพอมาเพิ่มcheckboxเข้าไปก็ใช่ไม่ได้ ชุดคำสั่งเหมือนเดิมหมดเลยครับ |
|
 |
|
|
 |
 |
|
ผมมาเพิ่มเข้าตัวเลือกเข้ามาอะครับ พอเพิ่มแล้วมันกลับไม่ได้ซะงั้น
สามารถค้นด้วย keyword ได้ แต่เช็คไม่ได้ครับ ของเก่ายังใช่ได้อยุ่เลย
ช่วยดีทีครับ
ขอบคุณครับ
อันนี้คืออันใหม่นะครับ
Code (PHP)
<table width="1000" align="center">
<tr>
<td colspan="3" valign="bottom" nowrap="nowrap"><p><strong>คำค้น </strong>
<input name="txtKeyword" type="text" id="txtKeyword2" value="<?=$_GET["txtKeyword"];?>" size="50" />
</p>
<p>*** ไม่สามารถค้นหา ชื่อพร้อมนามสกุลได้ และไม่ต้องใส่คำนำหน้า</p> <strong>การดำเนินงาน</strong>
<p>
<label>
<input type="checkbox" name="grade_[]" value="6" id="grade_6" />
รอผลการอนุมัติชื่อเรื่อง </label>
<label>
<input type="checkbox" name="grade_[]" value="5" id="grade_5" />
ผ่านการอนุมัติชื่อเรื่อง</label>
</p>
<p>
<input type="checkbox" name="grade_[]" value="9" id="grade_9" />
ไม่ผ่านการอนุมัติชื่อเรื่อง
<input type="checkbox" name="grade_[]" value="7" id="grade_7" />
ขออนุมัติการเสนองาน </p>
<p>
<input type="checkbox" name="grade_[]" value="8" id="grade_8" />
รอการส่งรูปเล่มรายงาน</p>
<p>
<label><strong>ผลการสอบ</strong><strong>ค้นหา</strong><br />
</label>
<label>
<input type="checkbox" name="grade_[]" value="1" id="grade_1" />
ดีเยี่ยม</label>
<label>
<input type="checkbox" name="grade_[]" value="2" id="grade_2" />
ดี</label>
<label>
<input type="checkbox" name="grade_[]" value="3" id="grade_3" />
ผ่าน</label>
<label>
<input type="checkbox" name="grade_[]" value="4" id="grade_4" />
ควรปรับปรุง</label>
</p>
<p>
<input type="submit" value="Search" onclick="frmSearch.command.value='SEARCH';"/>
</p></td>
</tr>
<tr>
<td colspan="3"><p>
<?
$command = $_GET["command"];
{
include("connect.php");
$grade = $_GET["grade"];
$txtKeyword = $_GET["txtKeyword"] ;
$url = '&txtKeyword='. $_GET["txtKeyword"] ;
for($i=0;$i<count($_GET["grade"]);$i++)
{
//if(trim($_GET["grade"][$i]) != "");
$url .= '&grade[]='. $_GET['grade'][$i];
}
$search_condition = "where ";
if(trim($txtKeyword)) {
$search_condition .= "( a.p_id LIKE '%$txtKeyword%'or a.p_stu_fname LIKE '%$txtKeyword%' or a.p_stu_sname LIKE '%$txtKeyword%' or c.p_adv_fname LIKE '%$txtKeyword%' or c.p_adv_sname LIKE '%$txtKeyword%' or a.p_name LIKE '%$txtKeyword%' or e.p_aca_w LIKE '%$txtKeyword%' )" ;
}
if (!empty($txtKeyword) && count($grade)!=0) {
$search_condition .= " and ";
}
if (count($grade)!=0) {
$search_condition .= "a.p_gra IN ('". implode("','", $grade) . "')";
}
$sql = " select a.* ,b.p_num,c.p_adv_num , c.p_adv_fname , c.p_adv_sname , d.p_gra_w , e.p_aca_w
from senior_n a left join senior_num b on (a.p_numkey = b.p_numkey)
left join senior_adv c on (a.p_adv = c.p_adv)
left join senior_gra d on (a.p_gra = d.p_gra)
left join senior_aca e on (a.p_aca = e.p_aca)
$search_condition ";
$objQuery = mysql_query($sql) ;
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 30;
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$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;
}
$sql .=" order by p_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($sql);
?>
</p>
<table width="993" border="1" align="center" class="square">
<tr bgcolor="#551B6D" style="color:#FFF;">
<td width="45" height="68" align="center"><strong>รหัส</strong></td>
<td width="273" align="center"><strong>ชื่อ Senior Project</strong></td>
<td width="170" align="center"><strong>ชื่อนักเรียน</strong></td>
<td width="170" align="center"><strong>ชื่ออาจารย์ที่ปรึกษา</strong></td>
<td width="161" align="center"><strong>การดำเนินงาน/ผลการเสนอ</strong></td>
<td width="64" align="center"><strong>ปีการศึกษา</strong></td>
<td width="64" align="center"><strong>บทคัดย่อ</strong></td>
</tr>
<?
$Num_Rows = 0;
while($objResult = mysql_fetch_array($objQuery)) {
$Num_Rows++;
if ($Num_Rows % 2 == 0){
?>
<tr bgcolor="#E9C8FB" >
<?
} else {
?>
</tr>
<tr bgcolor="#FFFFFF">
<?
}
?>
<td><div align="center">
<?=$objResult["p_id"]?>
</div></td>
<td><div align="left">
<?=$objResult["p_name"];?>
</div></td>
<td><div align="left">
<?=$objResult["p_num"];?>
<?=$objResult["p_stu_fname"];?>
<?=$objResult["p_stu_sname"];?>
</div></td>
<td><div align="left">
<?=$objResult["p_adv_num"];?>
<?=$objResult["p_adv_fname"];?>
<?=$objResult["p_adv_sname"];?>
</div></td>
<td><div align="center">
<?=$objResult["p_gra_w"]; ?>
</div></td>
<td><div align="center">
<?=$objResult["p_aca_w"]; ?>
</div></td>
<td><div align="center"><a href="/seniorproject/abs/<?=$objResult["p_abs_name"];?>" target='_blank'> บทคัดย่อ </a></div></td>
</tr>
<?
}
?>
</table>
<br />
ผลการค้นหาทั้งหมด
<?= $Num_Rows;?>
มีหน้าทั้งหมด :
<?=$Num_Pages;?>
หน้า :
<?
if($Prev_Page)
{
echo ' <a href="' . $_SERVER[SCRIPT_NAME] . '?Page=' . $Prev_Page . $url. '"><<หน้าก่อนหน้า</a>';
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo '[ <a href="'.$_SERVER[SCRIPT_NAME].'?Page='.$i . $url .'">'.$i.'</a> ]';
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo '<a href ="'. $_SERVER[SCRIPT_NAME].'?Page='. $Next_Page . $url .'">หน้าถัดไป>></a>';
}
mysql_close();
}
?></td>
</tr>
</table>
<p> </p>
</form>
ส่วนอันนี้คืออันเก่า
Code (PHP)
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>" size="50" />
<br />
<label>
<input type="checkbox" name="grade[]" value="1" id="grade_1" />
ดีเยี่ยม</label>
<label>
<input type="checkbox" name="grade[]" value="2" id="grade_2" />
ดี</label>
<label>
<input type="checkbox" name="grade[]" value="3" id="grade_3" />
ผ่าน</label>
<label>
<input type="checkbox" name="grade[]" value="4" id="grade_4" />
ควรปรับปรุง</label>
<label>
<input type="checkbox" name="grade[]" value="5" id="grade_5" />
รอการสอบ</label>
<input type="submit" value="Search" onclick="frmSearch.command.value='SEARCH';"/>
</p></th>
</tr>
<tr>
<td><?
$command = $_GET["command"];
{
include("connect.php");
$grade = $_GET["grade"];
$txtKeyword = $_GET["txtKeyword"] ;
$url = '&txtKeyword='. $_GET["txtKeyword"] ;
for($i=0;$i<count($_GET["grade"]);$i++)
{
$url .= '&grade[]='. $_GET['grade'][$i];
}
$search_condition = "where ";
if(trim($txtKeyword)) {
$search_condition .= "( a.p_id LIKE '%$txtKeyword%'or a.p_stu_fname LIKE '%$txtKeyword%' or a.p_stu_sname LIKE '%$txtKeyword%' or c.p_adv_fname LIKE '%$txtKeyword%' or c.p_adv_sname LIKE '%$txtKeyword%' or a.p_name LIKE '%$txtKeyword%' or e.p_aca_w LIKE '%$txtKeyword%' )" ;
}
if (!empty($txtKeyword) && count($grade)!=0) {
$search_condition .= " and ";
}
if (count($grade)!=0) {
$search_condition .= "a.p_gra IN ('". implode("','", $grade) . "')";
}
$sql = " select a.* ,b.p_num,c.p_adv_num , c.p_adv_fname , c.p_adv_sname , d.p_gra_w , e.p_aca_w
from senior_n a left join senior_num b on (a.p_numkey = b.p_numkey)
left join senior_adv c on (a.p_adv = c.p_adv)
left join senior_gra d on (a.p_gra = d.p_gra)
left join senior_aca e on (a.p_aca = e.p_aca)
$search_condition ";
$objQuery = mysql_query($sql) ;
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 30; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$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;
}
$sql .=" order by p_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($sql);
?>
<table width="993" border="1" align="center" class="square">
<tr bgcolor="#551B6D" style="color:#FFF;">
<td width="50" height="68" align="center"><strong>รหัส</strong></td>
<td width="292" align="center"><strong>ชื่อ Senior Project</strong></td>
<td width="180" align="center"><strong>ชื่อนักเรียน</strong></td>
<td width="170" align="center"><strong>ชื่ออาจารย์ที่ปรึกษา</strong></td>
<td width="93" align="center"><strong>ระดับคะแนน</strong></td>
<td width="83" align="center"><strong>ปีการศึกษา</strong></td>
<td width="79" align="center"><strong>บทคัดย่อ</strong></td>
</tr>
<?
$Num_Rows = 0;
while($objResult = mysql_fetch_array($objQuery)) {
$Num_Rows++;
if ($Num_Rows % 2 == 0){
?>
<tr bgcolor="#E9C8FB" >
<?
} else {
?>
</tr>
<tr bgcolor="#FFFFFF">
<?
}
?>
<td><div align="center">
<?=$objResult["p_id"]?>
</div></td>
<td><div align="left">
<?=$objResult["p_name"];?>
</div></td>
<td><div align="left">
<?=$objResult["p_num"];?>
<?=$objResult["p_stu_fname"];?>
<?=$objResult["p_stu_sname"];?>
</div></td>
<td><div align="left">
<?=$objResult["p_adv_num"];?>
<?=$objResult["p_adv_fname"];?>
<?=$objResult["p_adv_sname"];?>
</div></td>
<td><div align="center">
<?=$objResult["p_gra_w"]; ?>
</div></td>
<td><div align="center">
<?=$objResult["p_aca_w"]; ?>
</div></td>
<td><div align="center"><a href="/seniorproject/abs/<?=$objResult["p_abs_name"];?>" target='_blank'> บทคัดย่อ </a></div></td>
</tr>
<?
}
?>
</table>
<br />
ผลการค้นหาทั้งหมด
<?= $Num_Rows;?>
มีหน้าทั้งหมด :
<?=$Num_Pages;?>
หน้า :
<?
if($Prev_Page)
{
echo ' <a href="' . $_SERVER[SCRIPT_NAME] . '?Page=' . $Prev_Page . $url. '"><<หน้าก่อนหน้า</a>';
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo '[ <a href="'.$_SERVER[SCRIPT_NAME].'?Page='.$i . $url .'">'.$i.'</a> ]';
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo '<a href ="'. $_SERVER[SCRIPT_NAME].'?Page='. $Next_Page . $url .'">หน้าถัดไป>></a>';
}
mysql_close();
}
?></td>
</tr>
</table>
</form>
นี้คือส่วนที่มเพิ่มเข้าไปครับ
Code (PHP)
<label>
<input type="checkbox" name="grade_[]" value="6" id="grade_6" />
รอผลการอนุมัติชื่อเรื่อง </label>
<label>
<input type="checkbox" name="grade_[]" value="5" id="grade_5" />
ผ่านการอนุมัติชื่อเรื่อง</label>
</p>
<p>
<input type="checkbox" name="grade_[]" value="9" id="grade_9" />
ไม่ผ่านการอนุมัติชื่อเรื่อง
<input type="checkbox" name="grade_[]" value="7" id="grade_7" />
ขออนุมัติการเสนองาน </p>
<p>
<input type="checkbox" name="grade_[]" value="8" id="grade_8" />
รอการส่งรูปเล่มรายงาน</p>
Tag : PHP, MySQL, HTML/CSS, Action Script

|
ประวัติการแก้ไข 2013-02-13 19:38:41 2013-02-13 19:43:48
|
 |
 |
 |
 |
Date :
2013-02-13 18:45:49 |
By :
crazydrogon |
View :
661 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งงครับ ของเก่าได้ยังไง ของใหม่ไม่ได้ยังไง
อะไรที่เปลี่ยนแปลงไป เพิ่มเติมอะไรไป โค้ดอะไรที่เพิ่มไป
ขอคำอธิบายละเอียดๆ ด้วยครับ นอกจากคำว่าเช็คไม่ได้
|
 |
 |
 |
 |
Date :
2013-02-13 18:51:15 |
By :
cookiephp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณที่ช่วยเตือนครับพอดีรีบไปเลยไม่ได้สังเกตว่าcopyไม่ครับ
|
 |
 |
 |
 |
Date :
2013-02-13 19:39:21 |
By :
crazydrogon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|