|
 |
|
ในตารางสมาชิก เก็บรหัสสมาชิก ชื่อสมาชิก ส่วนตารางแจ็งซ่อม เก็บรหัสสมาชิก เลขที่ใบแจ้ง วันที่แจ้ง ต้องการค้นหาข้อมูลในตารางแจ็งซ่อม แต่ใช้ชื่อสมาชิกในการค้นหา |
|
 |
|
|
 |
 |
|
ใช้การ join น่ะ
มี 3 ตารางใช่ป่าว ก็
select table1.*, table2.*, table3.* from table1, table2, table3
where table1.id1 = table2.id1 and table2.id2 = table3.id2 and table2.name='ค่าที่ส่งมา'
ตรง where ก็คือ กำหนดว่า ไอดีของตาราง1 ต้องเท่ากับ ไอดีของตาราง2 เช็คให้ครบนะ เพื่อที่ข้อมูลจะออกมาถูกต้อง
|
 |
 |
 |
 |
Date :
2011-12-15 13:39:15 |
By :
บังเอิญผ่านมาเห็น |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช่ค่ะ ใช้อย่างคุณคนที่สามบอกค่ะ
ขอบคุณทุกข้อเสนอแนะน่ะค่ะ
โค้ดที่ทำได้แล้ว
Code (PHP)
<?
session_start();
if ($sess_adminid<>session_id()) {
header( "Location: admin.php"); exit();
}
include"fchkdate.php";
$cust_name=$_POST[cust_name]; //ชื่อที่รับมาจากtextfield
if($cust_name=="") {
echo "<H3>กรุณากรอกชื่อ-สกุลค่ะ</H3>";
exit();
}
include"connect.php";
$sql="select * from customer where cust_name='$cust_name'";
echo "$sql<BR>";
$result=mysql_db_query($dbname,$sql);
$rs=mysql_fetch_array($result);
$cust_id=$rs[cust_id];
$cust_name=$rs[cust_name];
$sql2="select * from repair where cust_id='$cust_id' ";
echo "$sql<BR>";
$result2=mysql_db_query($dbname,$sql2);
$rs2=mysql_fetch_array($result2);
$rep_id=$rs2[rep_id];
$daterep=$rs2[daterep];
$cust_id=$rs2[cust_id];
$serial_no=$rs2[serial_no];
$status_id=$rs2[status_id];
$sql4="select status_name from status where status_id='$status_id' "; //แสดงชื่อสถานะ
$result4=mysql_db_query($dbname,$sql4);
$rs4=mysql_fetch_array($result4);
$status_name=$rs4[status_name];
mysql_close();
?>
|
 |
 |
 |
 |
Date :
2011-12-15 15:10:24 |
By :
soon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|