테이블에서 데이터를 가져와 xml로 내보내는 스크립트가 있지만 두 개의 다른 테이블에서 데이터를 가져와야합니다.ID로 2 테이블에서 데이터를 선택하는 방법
Table 1: Products
i have inside:
id code
Table 2: Stock
i have inside
id qty
내 스크립트입니다 :
<?php
$db_host = "localhost";
$db_name = "test";
$db_username = "root";
$db_password = "";
$dbh = mysql_connect($db_host, $db_username, $db_password) or die("Unable to connect to MySQL");
mysql_query('SET NAMES "utf8"');
mysql_select_db($db_name, $dbh) or die("Could not select $db_name");
$sql = "select * from products ";
$q = mysql_query($sql);
$custom = '"';
$xml = "\n";
$xml .= "<XML>\n";
while($r = mysql_fetch_assoc($q))
{
$xml .= " <PRODUCT code=$custom " . $r["code"] . "$cusmot qty=$custom " . $r["qty"] . "$custom />\n";
}
$xml .= "</XML>";
header("Content-type: text/xml");
echo $xml;
?>
이 제품 테이블에 ID를 따라 증권 결과의 수량을 얻을 도움이 필요합니다.
어떤 도움을 환영합니다.
에서 작동하지 않습니다 .. 도와 줘서 고마워 !! – Dar
당신을 진심으로 환영합니다. 내 제안 된 쿼리가 어떻게 작동하지 않았는지 알려주실 수 있습니까? 스크립트를 작동 시켰습니까? –
경고 : mysql_fetch_assoc()은 매개 변수 1이 리소스가 될 것으로 예상하고, 부울은 – Dar