|
|
|
พี่ๆช่วยดู code updateทีคับ Web Service เขียนยังไงครับ พอจะมีตัวอย่างคร่าวๆ ไหมครับ |
|
|
|
|
|
|
|
คือมันไม่ยอมupdateให้อ่ะคับ แต่มันขึ้นนะคับว่า update complete งงมากเลยคับ
Code (PHP)
<?php
<?php
session_start();
include ("config.inc.php"); //include connection จากไฟล์ connectiondb.php
include ("utility.php");
//include ("showdata2.php");
require("menu.html");
//update
if( isset($_GET['uid']) && ! isset($_POST['name_cus']) ){
// BEFORE UPDATE
//msgbox("before update"); //redirect('testDB.php');
$id_name=$_GET['uid'];
$SQL= "select * from tbl_cus where id_name ='$id_name' ";
$RS = mysql_query($SQL);
$arr = mysql_fetch_array($RS);
$name_cus=$arr['name_cus'];
$position=$arr['position'];
$tel_c=$arr['tel_c'];
$email=$arr['email'];
$name_co=$arr['name_co'];
$post_c=$arr['post_c'];
//OpenTableMember();
//showdata2();
$btnDone = "update";
}else if( isset($_GET['uid']) && isset($_POST['name_cus']) ){
//UPDATE DATA
msgbox("update complete");
$id_name=$_GET['id_name'];
$name_cus = $_POST['name_cus'];
$position = $_POST['position'];
//$t = $_POST['rdosex'];
$tel_c = $_POST['tel_c'];
$email = $_POST['email'];
//$address = $_POST['txtaddress'];
$name_co = $_POST['name_co'];
$post_c = $_POST['post_c'];
$date_c=date("d/m/y");
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co'
post_c = '$post_c'
WHERE id_name = '$id_name' ";
mysql_query($SQL);
redirect('showdata2.php');
}else{
//echo 'Please Register';
//first open page
}
?>
<!-- ส่วนของ html -->
<!-- แสดงภาษาไทยบน webpage ตอน run -->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<p align="center"> </p>
<p align="center"><font face='Geneva, Arial, Helvetica, sans-serif' size='3' color='#0066FF'>แก้ไขข้อมูล</font></p>
<FORM METHOD=POST ACTION="">
<TABLE width="400" align="center">
<TR>
<TD width="99"><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>รายชื่อลูกค้า : </font></div></TD>
<TD width="232"><INPUT TYPE="text" NAME="name_cus" Value="<?php echo $name_cus;?>">*</TD>
</TR>
<TR>
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ตำแหน่ง : </font></div></TD>
<TD><INPUT TYPE="text" NAME="position" Value="<?php echo $position;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>โทรศัพท์ : </font></div></TD>
<TD><INPUT TYPE="text" NAME="tel_c" Value="<?php echo $tel_c;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>email : </font></div></TD>
<TD><INPUT TYPE="text" NAME="email" Value="<?php echo $email;?>"></TD>
</TR>
<!-- <TR >
<TD>Address</TD>
<TD><INPUT TYPE="text" NAME="txtaddress" Value=""></TD>
</TR> -->
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>บริษัท : </font></div></TD>
<TD><SELECT NAME="name_co">
<OPTION VALUE="1" <?php if($co==1) echo "selected" ;
$sql="select * from tbl_co order by id_co";
$result = mysql_query($sql);
while($fetcharr= mysql_fetch_array($result)){
$val = $fetcharr['id_co'];
$label = $fetcharr['name_co'];
echo "<option value=\"$val\">$label</option>\n";
};?>>
</SELECT></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ผู้โพส : </font></div></TD>
<TD><INPUT TYPE="text" NAME="post_c" Value="<?php echo $post_c;?>"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" value="ยืนยัน"></TD>
</TR>
</TABLE>
</FORM>
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-04-21 08:58:44 |
By :
weerayos |
View :
1723 |
Reply :
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co' //ลืม , ในส่วนนี้ไปครับ
post_c = '$post_c'
WHERE id_name = '$id_name' ";
|
|
|
|
|
Date :
2009-04-21 09:04:47 |
By :
windersun |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้อ่ะคับเหมือนเดิม
|
|
|
|
|
Date :
2009-04-21 09:18:16 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ง่า ไม่มีครายมาตอบเลยง่า
|
|
|
|
|
Date :
2009-04-21 10:00:10 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง echo $sql ตอนอัพเดทแล้วไปลอง run ใน โปรแกรม mysql ดูครับว่ามันได้หรือป่าวครับ
|
|
|
|
|
Date :
2009-04-21 10:19:34 |
By :
windersun |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ในส่วนที่เป็น
Code (PHP)
<?php
SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c'
WHERE id_name = '$id_name' ";
?>
อันนี้ใช่ไหมคับเอาไปรันใน Mysql ใช่ไหมคับ ลองแล้วคับรันได้คับอัพได้คับ ผมงงตรงส่วนที่ echo อ่ะคือยังไงงงอ่ะคับ
โทดทีคับผมมือใหม่เพิ่งหัดเขียนได้ไม่นานอ่ะคับ
|
|
|
|
|
Date :
2009-04-21 10:52:30 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเพิ่ม or die(mysql_error()); เข้าไปดูนะครับ
Code (PHP)
<?php
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co'
post_c = '$post_c'
WHERE id_name = '$id_name' ";
mysql_query($SQL) or die(mysql_error()); // เพิ่มตรงนี้นะครับ
?>
|
|
|
|
|
Date :
2009-04-21 11:00:01 |
By :
zepherus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วไงต่อคับ มันก็ขึ้นเหมือนเดิมอ่ะคับ
|
|
|
|
|
Date :
2009-04-21 11:20:58 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมงงไปหมดแล้วคับ
|
|
|
|
|
Date :
2009-04-21 11:22:00 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พอใส่ไปแล้วมันขึ้น ใส่ตัวนี้นะคับ $result = mysql_query($sql) or die(mysql_error()) แล้วมันขึ้น
Query was empty
|
|
|
|
|
Date :
2009-04-21 11:39:18 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมขอดูโค้ดตัวที่แก้แล้วได้ไหมครับ
|
|
|
|
|
Date :
2009-04-21 13:11:42 |
By :
zepherus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
<?php
session_start();
include ("config.inc.php"); //include connection จากไฟล์ connectiondb.php
include ("utility.php");
//include ("showdata2.php");
require("menu.html");
//update
if( isset($_GET['uid']) && ! isset($_POST['name_cus']) ){
// BEFORE UPDATE
//msgbox("before update"); //redirect('testDB.php');
$id_name=$_GET['uid'];
$SQL= "select * from tbl_cus where id_name ='$id_name' ";
$RS = mysql_query($SQL);
$arr = mysql_fetch_array($RS);
$name_cus=$arr['name_cus'];
$position=$arr['position'];
$tel_c=$arr['tel_c'];
$email=$arr['email'];
$name_co=$arr['name_co'];
$post_c=$arr['post_c'];
//OpenTableMember();
//showdata2();
$btnDone = "update";
}else if( isset($_GET['uid']) && isset($_POST['name_cus']) ){
//UPDATE DATA
msgbox("update complete");
$id_name=$_GET['id_name'];
$name_cus = $_POST['name_cus'];
$position = $_POST['position'];
//$t = $_POST['rdosex'];
$tel_c = $_POST['tel_c'];
$email = $_POST['email'];
//$address = $_POST['txtaddress'];
$name_co = $_POST['name_co'];
$post_c = $_POST['post_c'];
$date_c=date("d/m/y");
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($sql) or die(mysql_error()); // เพิ่มตรงนี้นะครับ
redirect('showdata2.php');
}else{
//echo 'Please Register';
//first open page
}
?>
<!-- ส่วนของ html -->
<!-- แสดงภาษาไทยบน webpage ตอน run -->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<p align="center"> </p>
<p align="center"><font face='Geneva, Arial, Helvetica, sans-serif' size='3' color='#0066FF'>แก้ไขข้อมูล</font></p>
<FORM METHOD=POST ACTION="">
<TABLE width="400" align="center">
<TR>
<TD width="99"><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>รายชื่อลูกค้า : </font></div></TD>
<TD width="232"><INPUT TYPE="text" NAME="name_cus" Value="<?php echo $name_cus;?>">*</TD>
</TR>
<TR>
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ตำแหน่ง : </font></div></TD>
<TD><INPUT TYPE="text" NAME="position" Value="<?php echo $position;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>โทรศัพท์ : </font></div></TD>
<TD><INPUT TYPE="text" NAME="tel_c" Value="<?php echo $tel_c;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>email : </font></div></TD>
<TD><INPUT TYPE="text" NAME="email" Value="<?php echo $email;?>"></TD>
</TR>
<!-- <TR >
<TD>Address</TD>
<TD><INPUT TYPE="text" NAME="txtaddress" Value=""></TD>
</TR> -->
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>บริษัท : </font></div></TD>
<TD><SELECT NAME="name_co">
<OPTION VALUE="1" <?php if($co==1) echo "selected" ;
$sql="select * from tbl_co order by id_co";
$result = mysql_query($sql);
while($fetcharr= mysql_fetch_array($result)){
$val = $fetcharr['id_co'];
$label = $fetcharr['name_co'];
echo "<option value=\"$val\">$label</option>\n";
};?>>
</SELECT></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ผู้โพส : </font></div></TD>
<TD><INPUT TYPE="text" NAME="post_c" Value="<?php echo $post_c;?>"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" value="ยืนยัน"></TD>
</TR>
</TABLE>
</FORM>
?>
นี่คับ
|
|
|
|
|
Date :
2009-04-21 13:22:24 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่รู้ผมใส่มั่วป่าวนะคับ ถ้ามั่วไปก็โทดทีคับ
|
|
|
|
|
Date :
2009-04-21 13:38:29 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ง่าไม่มีครายมาตอบเลยง่า
|
|
|
|
|
Date :
2009-04-21 14:31:02 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($sql) or die(mysql_error()); // เพิ่มตรงนี้นะครับ <= อันนี้ของคุณนะครับ
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($SQL) or die(mysql_error()); // เพิ่มตรงนี้นะครับ <= อันนี้ของผมนะครับ
?>
เห็นข้อแตกต่างไหมครับ ตรง mysql_query() ไงครับ
ของคุณใช้ตัวแปร $sql ซึ่งมันไม่มีตัวแปรนี้อยู่ แต่มันมีตัวแปร $SQL ครับ
ใน php $sql จะไม่เม่ากับ $SQL นะครับ ถ้าจำไม่ผิดเค้าเรียกว่า case sensitive ครับ
ถ้าลองใส่แล้วได้ผลประการใดรบกวนโพสแจ้งด้วยนะครับ
|
|
|
|
|
Date :
2009-04-21 14:44:47 |
By :
zepherus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หายแล้วคับไอตรง Query was empty แต่ก็ยังไม่อัพเดตเหมือนเดิมคับ
อันนี้โคดที่แก้แล้วคับ
Code (PHP)
<?php
<?php
session_start();
include ("config.inc.php"); //include connection จากไฟล์ connectiondb.php
include ("utility.php");
//include ("showdata2.php");
require("menu.html");
//update
if( isset($_GET['uid']) && ! isset($_POST['name_cus']) ){
// BEFORE UPDATE
//msgbox("before update"); //redirect('testDB.php');
$id_name=$_GET['uid'];
$SQL= "select * from tbl_cus where id_name ='$id_name' ";
$RS = mysql_query($SQL);
$arr = mysql_fetch_array($RS);
$name_cus=$arr['name_cus'];
$position=$arr['position'];
$tel_c=$arr['tel_c'];
$email=$arr['email'];
$name_co=$arr['name_co'];
$post_c=$arr['post_c'];
//OpenTableMember();
//showdata2();
$btnDone = "update";
}else if( isset($_GET['uid']) && isset($_POST['name_cus']) ){
//UPDATE DATA
msgbox("update complete");
$id_name=$_GET['id_name'];
$name_cus = $_POST['name_cus'];
$position = $_POST['position'];
//$t = $_POST['rdosex'];
$tel_c = $_POST['tel_c'];
$email = $_POST['email'];
//$address = $_POST['txtaddress'];
$name_co = $_POST['name_co'];
$post_c = $_POST['post_c'];
$date_c=date("d/m/y");
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($SQL) or die(mysql_error()); // เพิ่มตรงนี้นะครับ
redirect('showdata2.php');
}else{
//echo 'Please Register';
//first open page
}
?>
<!-- ส่วนของ html -->
<!-- แสดงภาษาไทยบน webpage ตอน run -->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<p align="center"> </p>
<p align="center"><font face='Geneva, Arial, Helvetica, sans-serif' size='3' color='#0066FF'>แก้ไขข้อมูล</font></p>
<FORM METHOD=POST ACTION="">
<TABLE width="400" align="center">
<TR>
<TD width="99"><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>รายชื่อลูกค้า : </font></div></TD>
<TD width="232"><INPUT TYPE="text" NAME="name_cus" Value="<?php echo $name_cus;?>">*</TD>
</TR>
<TR>
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ตำแหน่ง : </font></div></TD>
<TD><INPUT TYPE="text" NAME="position" Value="<?php echo $position;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>โทรศัพท์ : </font></div></TD>
<TD><INPUT TYPE="text" NAME="tel_c" Value="<?php echo $tel_c;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>email : </font></div></TD>
<TD><INPUT TYPE="text" NAME="email" Value="<?php echo $email;?>"></TD>
</TR>
<!-- <TR >
<TD>Address</TD>
<TD><INPUT TYPE="text" NAME="txtaddress" Value=""></TD>
</TR> -->
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>บริษัท : </font></div></TD>
<TD><SELECT NAME="name_co">
<OPTION VALUE="1" <?php if($co==1) echo "selected" ;
$sql="select * from tbl_co order by id_co";
$result = mysql_query($sql);
while($fetcharr= mysql_fetch_array($result)){
$val = $fetcharr['id_co'];
$label = $fetcharr['name_co'];
echo "<option value=\"$val\">$label</option>\n";
};?>>
</SELECT></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ผู้โพส : </font></div></TD>
<TD><INPUT TYPE="text" NAME="post_c" Value="<?php echo $post_c;?>"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" value="ยืนยัน"></TD>
</TR>
</TABLE>
</FORM>
?>
|
|
|
|
|
Date :
2009-04-21 15:04:42 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอ่อ ลองเอา msgbox("update complete"); ไปไว้หลัง Update ดูนะครับ
Code (PHP)
<?php
$id_name=$_GET['id_name'];
$name_cus = $_POST['name_cus'];
$position = $_POST['position'];
//$t = $_POST['rdosex'];
$tel_c = $_POST['tel_c'];
$email = $_POST['email'];
//$address = $_POST['txtaddress'];
$name_co = $_POST['name_co'];
$post_c = $_POST['post_c'];
$date_c=date("d/m/y");
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($SQL) or die(mysql_error()); // เพิ่มตรงนี้นะครับ
if($result)
{
msgbox("update complete");
}
else
{
msgbox("update incomplete");
}
redirect('showdata2.php');
?>
|
|
|
|
|
Date :
2009-04-21 15:27:10 |
By :
zepherus |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้เหมือนเดิมคับ
โคดที่แก้แล้ว
Code (PHP)
<?php
<?php
session_start();
include ("config.inc.php"); //include connection จากไฟล์ connectiondb.php
include ("utility.php");
//include ("showdata2.php");
require("menu.html");
//update
if( isset($_GET['uid']) && ! isset($_POST['name_cus']) ){
// BEFORE UPDATE
//msgbox("before update"); //redirect('testDB.php');
$id_name=$_GET['uid'];
$SQL= "select * from tbl_cus where id_name ='$id_name' ";
$RS = mysql_query($SQL);
$arr = mysql_fetch_array($RS);
$name_cus=$arr['name_cus'];
$position=$arr['position'];
$tel_c=$arr['tel_c'];
$email=$arr['email'];
$name_co=$arr['name_co'];
$post_c=$arr['post_c'];
//OpenTableMember();
//showdata2();
$btnDone = "update";
}else if( isset($_GET['uid']) && isset($_POST['name_cus']) ){
//UPDATE DATA
//msgbox("update complete");
$id_name=$_GET['id_name'];
$name_cus = $_POST['name_cus'];
$position = $_POST['position'];
//$t = $_POST['rdosex'];
$tel_c = $_POST['tel_c'];
$email = $_POST['email'];
//$address = $_POST['txtaddress'];
$name_co = $_POST['name_co'];
$post_c = $_POST['post_c'];
$date_c=date("d/m/y");
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($SQL) or die(mysql_error()); // เพิ่มตรงนี้นะครับ
if($result)
{
msgbox("update complete");
}
else
{
msgbox("update incomplete");
}
redirect('showdata2.php');
//echo 'Please Register';
//first open page
}
?>
<!-- ส่วนของ html -->
<!-- แสดงภาษาไทยบน webpage ตอน run -->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<p align="center"> </p>
<p align="center"><font face='Geneva, Arial, Helvetica, sans-serif' size='3' color='#0066FF'>แก้ไขข้อมูล</font></p>
<FORM METHOD=POST ACTION="">
<TABLE width="400" align="center">
<TR>
<TD width="99"><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>รายชื่อลูกค้า : </font></div></TD>
<TD width="232"><INPUT TYPE="text" NAME="name_cus" Value="<?php echo $name_cus;?>">*</TD>
</TR>
<TR>
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ตำแหน่ง : </font></div></TD>
<TD><INPUT TYPE="text" NAME="position" Value="<?php echo $position;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>โทรศัพท์ : </font></div></TD>
<TD><INPUT TYPE="text" NAME="tel_c" Value="<?php echo $tel_c;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>email : </font></div></TD>
<TD><INPUT TYPE="text" NAME="email" Value="<?php echo $email;?>"></TD>
</TR>
<!-- <TR >
<TD>Address</TD>
<TD><INPUT TYPE="text" NAME="txtaddress" Value=""></TD>
</TR> -->
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>บริษัท : </font></div></TD>
<TD><SELECT NAME="name_co">
<OPTION VALUE="1" <?php if($co==1) echo "selected" ;
$sql="select * from tbl_co order by id_co";
$result = mysql_query($sql);
while($fetcharr= mysql_fetch_array($result)){
$val = $fetcharr['id_co'];
$label = $fetcharr['name_co'];
echo "<option value=\"$val\">$label</option>\n";
};?>>
</SELECT></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ผู้โพส : </font></div></TD>
<TD><INPUT TYPE="text" NAME="post_c" Value="<?php echo $post_c;?>"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" value="ยืนยัน"></TD>
</TR>
</TABLE>
</FORM>
?>
|
|
|
|
|
Date :
2009-04-21 15:37:43 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$id_name=$_GET['id_name'];
?>
น่าจะเป็น
Code (PHP)
<?php
$id_name=$_GET['uid'];
?>
|
|
|
|
|
Date :
2009-04-21 16:10:46 |
By :
lozomac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วคับ
อันนี้ที่แก้แล้วคับ ขอบคุณคุณมากคับ สำหรับทุกๆคำตอบ
Code (PHP)
<?php
<?php
session_start();
include ("config.inc.php"); //include connection จากไฟล์ connectiondb.php
include ("utility.php");
//include ("showdata2.php");
require("menu.html");
//update
if( isset($_GET['uid']) && ! isset($_POST['name_cus']) ){
// BEFORE UPDATE
//msgbox("before update"); //redirect('testDB.php');
$id_name=$_GET['uid'];
$SQL= "select * from tbl_cus where id_name ='$id_name' ";
$RS = mysql_query($SQL);
$arr = mysql_fetch_array($RS);
$name_cus=$arr['name_cus'];
$position=$arr['position'];
$tel_c=$arr['tel_c'];
$email=$arr['email'];
$name_co=$arr['name_co'];
$post_c=$arr['post_c'];
//OpenTableMember();
//showdata2();
$btnDone = "update";
}else if( isset($_GET['uid']) && isset($_POST['name_cus']) ){
//UPDATE DATA
//msgbox("update complete");
$id_name=$_GET['uid'];
$name_cus = $_POST['name_cus'];
$position = $_POST['position'];
//$t = $_POST['rdosex'];
$tel_c = $_POST['tel_c'];
$email = $_POST['email'];
//$address = $_POST['txtaddress'];
$name_co = $_POST['name_co'];
$post_c = $_POST['post_c'];
$date_c=date("d/m/y");
$SQL= " UPDATE tbl_cus SET
name_cus = '$name_cus',
position = '$position',
tel_c = '$tel_c',
email = '$email',
name_co = '$name_co',
post_c = '$post_c',
date_c = '$date_c'
WHERE id_name = '$id_name' ";
$result = mysql_query($SQL) or die(mysql_error()); // เพิ่มตรงนี้นะครับ
if($result)
{
msgbox("update complete");
}
else
{
msgbox("update incomplete");
}
redirect('showdata2.php');
//echo 'Please Register';
//first open page
}
?>
<!-- ส่วนของ html -->
<!-- แสดงภาษาไทยบน webpage ตอน run -->
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8" />
<p align="center"> </p>
<p align="center"><font face='Geneva, Arial, Helvetica, sans-serif' size='3' color='#0066FF'>แก้ไขข้อมูล</font></p>
<FORM METHOD=POST ACTION="">
<TABLE width="400" align="center">
<TR>
<TD width="99"><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>รายชื่อลูกค้า : </font></div></TD>
<TD width="232"><INPUT TYPE="text" NAME="name_cus" Value="<?php echo $name_cus;?>">*</TD>
</TR>
<TR>
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ตำแหน่ง : </font></div></TD>
<TD><INPUT TYPE="text" NAME="position" Value="<?php echo $position;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>โทรศัพท์ : </font></div></TD>
<TD><INPUT TYPE="text" NAME="tel_c" Value="<?php echo $tel_c;?>"></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>email : </font></div></TD>
<TD><INPUT TYPE="text" NAME="email" Value="<?php echo $email;?>"></TD>
</TR>
<!-- <TR >
<TD>Address</TD>
<TD><INPUT TYPE="text" NAME="txtaddress" Value=""></TD>
</TR> -->
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>บริษัท : </font></div></TD>
<TD><SELECT NAME="name_co">
<OPTION VALUE="1" <?php if($co==1) echo "selected" ;
$sql="select * from tbl_co order by id_co";
$result = mysql_query($sql);
while($fetcharr= mysql_fetch_array($result)){
$val = $fetcharr['id_co'];
$label = $fetcharr['name_co'];
echo "<option value=\"$val\">$label</option>\n";
};?>>
</SELECT></TD>
</TR>
<TR >
<TD><div align="right"><font face='Geneva, Arial, Helvetica, sans-serif' size='2' color='#0066FF'>ผู้โพส : </font></div></TD>
<TD><INPUT TYPE="text" NAME="post_c" Value="<?php echo $post_c;?>"></TD>
</TR>
<TR>
<TD></TD>
<TD><INPUT TYPE="submit" value="ยืนยัน"></TD>
</TR>
</TABLE>
</FORM>
?>
|
|
|
|
|
Date :
2009-04-22 08:22:33 |
By :
weerayos |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|