updateไม่ได้ ใครรู้ช่วยบอกที

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

joylukmhu
PHP Newbie
PHP Newbie
โพสต์: 5
ลงทะเบียนเมื่อ: 23/01/2009 2:18 pm

updateไม่ได้ ใครรู้ช่วยบอกที

โพสต์ที่ยังไม่ได้อ่าน โดย joylukmhu »

<?
ob_start();
?>
<?
session_start();
require_once("../db/conn_db.php");
require_once("../lib/configs.php");
conn_db();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>แก้ไขหมวดหมู่หลักสูตร</title>
<link href="style1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style5 {
font-family: Tahoma;
font-size: 18px;
color: #FF6600;
}
.style7 {
color: #FF6600;
font-size: 14px;
font-family: Tahoma;
font-weight: bold;
}
-->
</style>
</head>
<body>
<link href="style1.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: 24px}
.style2 {
color: #FF3300;
font-weight: bold;
font-size: 16px;
font-family: Tahoma;
}
.style3 {font-family: Tahoma}
-->
</style>
</head>
<script language="javascript" type="text/javascript">
function Exit(){
window.location.href = "../home/index.php";
}

function checkdata(group){
if(group.id_group.value == ""){
alert("กรุณากรอกรหัสหมวดหมู่");
group.id_group.focus();
return false;
}

if(group.group_name.value == ""){
alert("กรุณากรอกชื่อหมวดหมู่ที่ต้องการเพิ่ม");
group.group_name.focus();
return false;
}
return true;
}

function submitgroup(){
if(checkdata(document.group)){
group.status.value = 1;
document.group.submit();
}
else{
group.status.value = 0;
}
}
</script>
<?
if($status==1){
$id_group = $_GET['id_group'];
$group_name = $_POST['group_name'];
echo $mysql_error();
$sql= "update group_train set id_group='$id_group',group_name='$group_name' where id_group='$id_train'";
$result=mysql_db_query($sql);
echo $sql;
mysql_query($sql) or die ("SQL ERROR!!!");
?>
<script language="javascript" type="text/javascript">
window.location.herf = "listtrain_group.php";
</script>
<? }
if(!empty($id_group)){
$sql= " select * from group_train where id_group='$id_group' ";
$result=mysql_query($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$id_group = $row[id_group];
$group_name = $row[group_name];
}
?>
<body>
<? require_once("../home/header.php"); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
<tr bgcolor="#FFCCCC">
<td width="85%">&nbsp;</td>
<td width="9%"><img src="../images/restore_f2.png" style="cursor:hand;" onclick="Exit()" /></td>
<td width="6%" valign="middle">Exit</td>
</tr>
</table>
<form name="group" method="post" action="">
<input name="status" type="hidden" value="0" />
<p align="center" class="style5">แก้ไขส่วนที่ต้องการ</p>
<table width="269" height="30" border="3" align="center" bordercolor="#FF3300">
<tr>
<td width="109" bgcolor="#FFFFCC"><div align="center" class="style7">รหัสหมวดหมูู่่</div></td>
<td width="144"><input name="id_group" type="text" class="text100" value="
<? print $id_group?>"/></td>
</tr>
<tr>
<td width="109" bgcolor="#FFFFCC"><div align="center" class="style7">ชื่อหมวดหมู่ที่่ต้องการเพิ่ม</div></td>
<td width="144"><input name="group_name" type="text" class="text100" value="<? print $group_name?>"/></td>
</tr>
</table>
<p align="center">
<label class="btn">
<input name="Button" type="button" class="btn" value="Save" onclick="submitgroup()" />
</label>
</p>
</form>
<? require_once("../home/footer.php");?>
</body>
</html>
<?
ob_end_flush();
?>
มัน uodate ไม่ได้ ไม่รู้ว่าผิดตรงไหน ใครรู้แล้วช่วยบอกทีน่ะค่ะ งง มาหลายวันแล้ว
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: updateไม่ได้ ใครรู้ช่วยบอกที

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

น่าจะอธิบายคร่าวๆ หรือ ละเอียดหน่อยก็ดีนะครับ ว่ากำลังทำอะไร มี Error อะไร หรือเปล่า
หรือ มันผิดปกติ ที่ส่วนไหนของไฟล์
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
joylukmhu
PHP Newbie
PHP Newbie
โพสต์: 5
ลงทะเบียนเมื่อ: 23/01/2009 2:18 pm

Re: updateไม่ได้ ใครรู้ช่วยบอกที

โพสต์ที่ยังไม่ได้อ่าน โดย joylukmhu »

คือว่าต้องการ update ข้อมูล โดยที่ต้องการให้กลุ่มกับชื่อกลุ่ม updateแทนของเก่า แล้ว update ไม่ได้ error ก็ไม่มีแจ้งให้รู้ เลยไม่รู้ว่ามันผิดตรงไหน ยังไงก็ช่วยดูให้หน่อยได้มั้ยค่ะ
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: updateไม่ได้ ใครรู้ช่วยบอกที

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

ลองเช็คตรงนี้ดูอีกทีครับ

โค้ด: เลือกทั้งหมด

$id_group = $_GET['id_group']; <--------------รับค่ามาจากไหน
$group_name = $_POST['group_name'];    <--------------รับค่ามาจากไหน
echo $mysql_error();    <------------------- ใส่เพื่ออะไร 
$sql= "update group_train set id_group='$id_group',group_name='$group_name' where id_group='$id_train'";
$result=mysql_db_query($sql); <--------------- parameter ที่ใส่ ไม่ถูกต้อง mysql_db_query ต้องระบุชื่อฐานข้อมูลด้วย

ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
joylukmhu
PHP Newbie
PHP Newbie
โพสต์: 5
ลงทะเบียนเมื่อ: 23/01/2009 2:18 pm

Re: updateไม่ได้ ใครรู้ช่วยบอกที

โพสต์ที่ยังไม่ได้อ่าน โดย joylukmhu »

ยังงงอยู่เลยค่ะ แก้แล้วแต่ก็ยังไม่ได้ ขอแบบละเอียดหน่อยได้มั้ยค่ะ ขอบคุณค่ะ
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41232
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: updateไม่ได้ ใครรู้ช่วยบอกที

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

แก้ไปยังไง ล่ะครับ
ลองตอบตัวเองให้ได้ว่าที่ผมใช้เครื่องหมาย <--------------
ไว้เอาค่ามาจากไหน
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 105