我有这些表格,我希望获得某些数据供用户查看并能够发布到其他页面
我无法发布图片,因此我必须将其分解,所以请耐心等待我
1st table
- dbo.users
- pkey(UserID)
- EmployeeName
2nd table
- dbo.PC
- pkey(PCID)
- PC_Number
3rd table
- dbo.FA_PC
- pkey(FAID)
- fkey(UserID)
- fkey(PCID)
<?php
ini_set("display_errors","on");
$conn = new COM("ADODB.Connection");
try {
$myServer = "WTCPHFILESRV\WTCPHINV";
$myUser = "sa";
$myPass = "P@ssw0rd";
$myDB = "wtcphitinventory";
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB;
$conn->open($connStr);
if (! $conn) {
throw new Exception("Could not connect!");
}
}
catch (Exception $e) {
echo "Error (File:): ".$e->getMessage()."<br>";
}
if (!$conn)
{
exit("Connection Failed: " . $conn);
}
$sql_exp = "select * from dbo.users";
$rs = $conn->Execute($sql_exp);
echo "<select name='empf'>";
while (!$rs->EOF) {
set_time_limit(0);
echo "<option value=".$rs->Fields('UserID')." >".$rs->Fields('EmployeeName')."</option>";
$rs->MoveNext();
}
$rs->Close();
?>
如何以相同的形式显示当前所选PC_Number
的{{1}},并且仍然可以将其发布在printd.php上
答案 0 :(得分:0)
尝试INNER JOINS
select A.*,B.*,C.* from table1 A INNER JOIN Table2 B ON A.userid=B.userid
INNER JOIN table3 C ON C.pcid=B.pcid where A.userid='2'
祝你好运