|
|
|
การ select ข้อมูลจากตารางหนึ่งไปอีกตารางหนึ่ง แล้วให้ข้อมูลที่ selsct นั้นหายไปจากแถวด้วย ทำยังไงค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
include "connect1.php";
?>
<!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>
<style type="text/css">
<!--
.font {
font-family: Tahoma, Geneva, sans-serif;
font-size: 12px;
}
-->
body {
margin: 0px;
padding: 0px;
font-size: 12px;
}
</style>
<style type="text/css">
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>
<body>
<form id="form2" name="form2" method="post" action="showproblem.php">
<table width="811" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<th align="center" scope="col">ลำดับ</th>
<th align="center" scope="col">วันที่แจ้ง</th>
<th align="center" scope="col">เรื่อง</th>
<th align="center" scope="col">ชื่อ-นามสกุล</th>
<th align="center" scope="col">สถานะ</th>
</tr>
<input name="id3" type="hidden" id="id3" value="<?=$_REQUEST['id3'];?>" />
<tr align="center">
<td> <input name="id3" type="text" disabled="disabled" id="id3" value="<?=$_REQUEST['id3'];?>" /></td>
<td><input name="date" type="text" disabled="disabled" id="date" value="<?=$_REQUEST['date'];?>" /></td>
<td><input name="title" type="text" disabled="disabled" id="title" value="<?=$_REQUEST['title'];?>" /></td>
<td><input name="name" type="text" disabled="disabled" id="name" value="<?=$_REQUEST['name'];?>" /></td>
<td><input name="status3" type="text" disabled="disabled" id="status3" value="<?=$_REQUEST['status3'];?>" /></td>
</tr>
</table>
</form>
<form id="form1" name="form1" method="post" action="">
<?
$id3=$_REQUEST['id3'];
$sql="select * from information i ,staff_user su where i.SU_ID=su.SU_ID and i.P_ID=$id3";
//echo $sql;
$dbquery = mysql_db_query($database_c, $sql);
$num_rows = mysql_num_rows($dbquery);
if( $num_rows>0)
{
?>
<table width="314" border="1" align="center" cellpadding="0" cellspacing="0">
<tr align="center">
<th colspan="6" scope="col">ผู้แก้ไขปัญหา</th>
</tr>
<tr align="center">
<td scope="col">รหัสพนักงาน</td>
<td scope="col">ชื่อ-นามสกุล</td>
<td scope="col">วันที่รับงาน</td>
<td scope="col">ลบ</td>
</tr><?
while ($row=mysql_fetch_array($dbquery)){
$pid=$row['P_ID'];
$id2=$row['SU_ID'];
$first2=$row['SU_firstname'];
$last2=$row['SU_lastname'];
$name2=$first2." ".$last2;
$date2=$row['I_date'];
if( $date2=='')
{ $d='<a href=delstaffs.php?SU_ID='.$id2.'&P_ID='.$pid.'><img src="images/user_red.png" width="16" height="16" border="0"/></a>';
}
else {
$d=' ';
}
?>
<tr align="center">
<td scope="col"><? echo $id2;?></td>
<td scope="col"><? echo $name2;?></td>
<td scope="col"><? echo $date2; ?> </td>
<td scope="col"><?=$d?> </td>
</tr>
<? }} ?>
</table>
</form>
<form id="form3" name="form3" method="post" action="">
<table width="408" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" scope="col">ค้นหาผู้แก้ปัญหา
<select name="search" id="search">
<option value="0" selected>กรุณาเลือก</option>
<option value="SU_ID" >รหัสพนักงาน</option>
<option value="SU_firstname">ชื่อ</option>
</select></td>
<th align="center" scope="col"><input type="text" name="box" id="box" /></th>
<th align="center" scope="col"><input type="submit" name="submit" id="submit" value="ค้นหา" /></th>
</tr>
<tr>
<td width="156" align="center" scope="col"> </td>
<th width="144" align="center" style="" scope="col"> </th>
<th width="50" align="center" scope="col"> </th>
</tr>
</table>
</form>
<form id="form1" name="form1" method="post" action="edithistory.php">
<table width="524" border="1" align="center" cellpadding="0" cellspacing="0">
<th width="77" align="center">รหัสพนักงาน</th>
<th width="116" align="center">ชื่อ-นามสกุล</th>
<th width="68" align="center">แผนก</th>
<th width="55" align="center">ตำแหน่ง</th>
<th width="73" align="center">สถานะ</th>
<th width="82" align="center">บริษัท</th>
<th align="center">เลือก</th>
<?
include "function.php";
if($_REQUEST['submit'])
{
$box=$_REQUEST['box'];
$search=$_REQUEST['search'];
$id3=$_REQUEST['id3'];
echo $id3;
//echo "$box";
//echo "$search";
$sql="select * from staff_user where $search like '%$box%' and Type_of_potential ='1'";
echo $sql;
}
else {
$sql="select * from staff_user where Type_of_potential ='1'"; }
//echo $sql;
$dbquery = mysql_db_query($database_c, $sql);
$num_rows = mysql_num_rows($dbquery);
//echo $num_rows;
if( $num_rows>0)
{
while ($row=mysql_fetch_array($dbquery)){
$subject=$row['SU_ID'];
$subject1=$row['SU_firstname'];
$subject2=$row['SU_lastname'];
$subject3=$row['D_ID'];
$subject4=$row['POS_ID'];
$subject5=$row['Type_of_potential'];
$subject6= getidc($row['C_ID']);
$name=$subject1." ".$subject2;
//echo $subject5;
if($subject5=="0")
{
$a="user";
}
else if($subject5=="1")
{
$a="staff";
}
else if($subject5=="2")
{
$a="superviser";
}
else if($subject5=="3")
{
$a="admin";
}
// $id=$_REQUEST['edit_id'];
?>
<tr>
<td align="center" scope="col"><? echo $subject?></td>
<td align="center" scope="col"><? echo $name?></td>
<td align="center" scope="col"><? echo $subject3?></td>
<td align="center" scope="col"><? echo $subject4?></td>
<td align="center" scope="col"><? echo $a?></td>
<td align="center" scope="col"><? echo $subject6?></td>
<td width="35" align="center" scope="col"><a href=checkaddstaff.php?P_ID=<?=$id3?>&SU_ID=<?=$subject?>><img src="images/user_red.png" width="16" height="16" border="0"/></td>
</tr>
<?
}
}
?>
</table>
</form>
</body>
</html>
Tag : PHP, JavaScript
|
|
|
|
|
|
Date :
2012-09-26 08:54:36 |
By :
kawapoona |
View :
1206 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หมายถึง เอาข้อมูลจากตารางแรก ไปใส่ตารางที่สอง ละลบข้อมูลตารางแรกออกเหรอ
select(ตารางแรก) -> insert(ตารางสอง) -> delete(ตารางแรก)
งี้เหรอครับ
|
|
|
|
|
Date :
2012-09-26 09:05:48 |
By :
popypreaw |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช่ค่ะ จะทำยังไงดีค่ะ
|
|
|
|
|
Date :
2012-09-26 09:07:30 |
By :
kawapoona |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sql = "select * from table1";
$query = mysql_query($sql);
while($res = mysql_fetch_array($query)){
$res1 = $res["field_1"];//ถ้ามีหลายฟิลด์ก็สร้างตัวแปรขึ้นมาอีก
$sqlI = "insert into table2 value('$res1')";
$queryI = mysql_query($sqlI);
$sqlD = "delete table1 set field_1 = '$res1'";
$queryD = mysql_query($sqlD);
}
ประมาณนี้อะครับ
|
|
|
|
|
Date :
2012-09-26 09:16:07 |
By :
popypreaw |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากค่ะ เด๋วจะลองเอาไปใช้ดูค่ะ
|
|
|
|
|
Date :
2012-09-26 09:21:19 |
By :
kawapoona |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|