|
 |
|
ช่วยดูโค้ดให้หน่อยคับ ผิด ตรงไหน พยายามจะ ทำการอัพเดท สถานะ อะคับ |
|
 |
|
|
 |
 |
|
ทำไมเอา function confirm ไปไว้ใน loop หล่ะครับ
ลองปรับดูน่ะ
Code (PHP)
<? //session_start();?>
<?
$objConnect = mysql_connect("localhost","root", '12345') or die("Error Connect to Database");
$objDB = mysql_select_db("studentloan_ku_kps");
$strSQL = "SELECT * FROM alert";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // 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;
}
$strSQL .=" order by alert_id DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
</head>
<body>
<table width="770" height="48" border="0">
<tr>
<td width="259"><div align="center"><strong>ชื่อ-นามสุกล</strong></div></td>
<td width="87">
<div align="center"><strong>รหัสนิสิต</strong></div>
</td>
<td width="129"><div align="center"><strong>วันที่ข้อมูลเข้าระบบ</strong></div></td>
<td width="72"><div align="center"><strong>สถานะ</strong></div></td>
<td width="201"><div align="center"><strong>ผลการตรวจเอกสาร</strong></div></td>
</tr>
<tr> <?
while($objResult = mysql_fetch_array($objQuery))
{
$sql2="update alert set alert_status='2' where nisit_id=$nisit_id";
mysql_query($sql2);
?>
<td><?=$objResult["alert_name"]." ".$objResult["alert_sname"]; ?></td>
<td> <?=$objResult["nisit_id"]; ?></td>
<td><div align="center"><?=$objResult["alert_date"]; ?></div></td>
<td><div align="center"><? if($objResult["alert_status"]== "1") {echo "รอพิจารณา";}
if($objResult["alert_status"]== "2") {echo "ผ่านการตรวจแล้ว";}
if($objResult["alert_status"]== "3") {echo "ยังขาดเอกสาร";}?></div></td>
<td><center>
<? if($objResult["alert_status"]== "1") { ?>
<input type="submit" name="button" id="button" value="ครบ" OnClick="chkConfirm(<?=$objResult["nisit_id"]; ?>)" />
<input type="submit" name="button2" id="button2" value="ไม่ครบ" /> <? }else { echo "ตรวจแล้ว" ;} ?>
</center></td>
</tr> <? } ?>
</table>
<?php /*?>Total <?= $Num_Rows;?> <?php */?>
จำนวน:
<?=$Num_Pages;?> หน้า :
<?
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);
?>
</body>
<script language="JavaScript">
function chkConfirm(nisitID)
{
if(confirm('ตรวจสอบเอกสารเรียบร้อยแล้ว')==true)
{
alert('นิสิตได้ผ่านการตรวจเอกสารแล้ว');
window.location = 'index_offi_edit.php? nisit_id='+nisitID;
}
else
{
alert('ยกเลิก');
}
}
</script>
</html>
|
 |
 |
 |
 |
Date :
2014-01-23 22:11:09 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณคับ ส่งค่า insit_id ตอนคลิกไปได้คับ แต่พอขึ้น alert แล้วรีเฟสหน้า มันไม่ เช็ค เปลี่ยนสถานะ ให้
เจ้าปุ่ม บอททอม ยัง อยู่ ต้องกด รีเฟส หน้า อีกที ถึง จะรู้ว่า "ผ่านการตรวจแล้ว" กับ "ตรวจแล้ว"
Code (PHP)
<? if($objResult["alert_status"]== "1") { ?>
<input type="submit" name="button" id="button" value="ครบ" OnClick="chkConfirm()" />
<input type="submit" name="button2" id="button2" value="ไม่ครบ" /> <? }else { echo "ตรวจแล้ว" ;} ?>
มีวิธีที่ทำให้มันแสดง เลยไหม อะคับ ไม่ต้อง รีเฟสเอง
|
 |
 |
 |
 |
Date :
2014-01-23 22:49:17 |
By :
komza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไมโค้ดไม่เหมือนที่ผมปรับให้ครับ
Code (PHP)
<? if($objResult["alert_status"]== "1") { ?>
<input type="submit" name="button" id="button" value="ครบ" OnClick="chkConfirm(<?=$objResult["nisit_id"]; ?>)" />
<input type="submit" name="button2" id="button2" value="ไม่ครบ" /> <? }else { echo "ตรวจแล้ว" ;} ?>
แล้วก็ขอดูโค้ดหน้า index_offi_edit.php ด้วยครับ
|
 |
 |
 |
 |
Date :
2014-01-24 06:24:13 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมให้มัน รีเฟส กับมาเดิม อะคับ แบบว่า อยากให้ กดปุบ แล้วรีเฟส แล้ว เปลี่ยน สถานะ เลย
แต่ที่ ลอง คือ มันต้องเก็บส่งก่อน แล้ว ค่อยรีเฟส ถึงจะออก หรือ ผม ต้องวนรีเฟสอีก รอบ รึป่าวคับ
index_offi_edit.php
Code (PHP)
<? //session_start();?>
<?
$objConnect = mysql_connect("localhost","root", '12345') or die("Error Connect to Database");
$objDB = mysql_select_db("studentloan_ku_kps");
$strSQL = "SELECT * FROM alert";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // 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;
}
$strSQL .=" order by alert_id DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
</head>
<body>
<table width="770" height="48" border="0">
<tr>
<td width="259"><div align="center"><strong>ชื่อ-นามสุกล</strong></div></td>
<td width="87">
<div align="center"><strong>รหัสนิสิต</strong></div>
</td>
<td width="129"><div align="center"><strong>วันที่ข้อมูลเข้าระบบ</strong></div></td>
<td width="72"><div align="center"><strong>สถานะ</strong></div></td>
<td width="201"><div align="center"><strong>ผลการตรวจเอกสาร</strong></div></td>
</tr>
<tr> <?
while($objResult = mysql_fetch_array($objQuery))
{
$sql2="update alert set alert_status='2' where nisit_id=$nisit_id";
mysql_query($sql2);
?>
<td><?=$objResult["alert_name"]." ".$objResult["alert_sname"]; ?></td>
<td> <?=$objResult["nisit_id"]; ?></td>
<td><div align="center"><?=$objResult["alert_date"]; ?></div></td>
<td><div align="center"><? if($objResult["alert_status"]== "1") {echo "รอพิจารณา";}
if($objResult["alert_status"]== "2") {echo "ผ่านการตรวจแล้ว";}
if($objResult["alert_status"]== "3") {echo "ยังขาดเอกสาร";}?></div></td>
<td><center>
<? if($objResult["alert_status"]== "1") { ?>
<input type="submit" name="button" id="button" value="ครบ" OnClick="chkConfirm(<?=$objResult["nisit_id"]; ?>)" />
<input type="submit" name="button2" id="button2" value="ไม่ครบ" /> <? }else { echo "ตรวจแล้ว" ;} ?>
</center></td>
</tr> <? } ?>
</table>
<?php /*?>Total <?= $Num_Rows;?> <?php */?>
จำนวน:
<?=$Num_Pages;?> หน้า :
<?
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);
?>
</body>
<script language="JavaScript">
function chkConfirm(nisitID)
{
if(confirm('ตรวจสอบเอกสารเรียบร้อยแล้ว')==true)
{
alert('นิสิตได้ผ่านการตรวจเอกสารแล้ว');
window.location = 'index_offi_edit.php? nisit_id='+nisitID;
}
else
{
alert('ยกเลิก');
}
}
</script>
</html>
|
ประวัติการแก้ไข 2014-01-24 10:55:39 2014-01-24 10:56:10
 |
 |
 |
 |
Date :
2014-01-24 10:52:01 |
By :
komza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
code update คือชุดนี้ป่ะครับ
Code (PHP)
$sql2="update alert set alert_status='2' where nisit_id=$nisit_id";
mysql_query($sql2);
|
 |
 |
 |
 |
Date :
2014-01-24 14:19:38 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แนวคิดแล้วคับ แค่แยก ตัวคำสั่ง Code (PHP)
$sql2="update alert set alert_status='2' where nisit_id=$nisit_id";
mysql_query($sql2);
ไปไหนสักเพจ เช่น เพจอัพเดท แล้วใช่คำสั่ง window.location ='เพจเดิม' ก็ ทำให้ไม่ต้องรีเฟส 2 รอบและ คับ
ขอบ คุณ mangkunzo ที่ช่วยให้คำแนะนำ สำหรับการอัพเดท คับ
|
 |
 |
 |
 |
Date :
2014-01-24 18:12:03 |
By :
komza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2014-01-25 09:04:56 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะ ใช่ ajax เข้ามาช่วย อาจจะดีขึ้น 
|
 |
 |
 |
 |
Date :
2014-01-25 09:46:29 |
By :
konnatee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|