テーブルからデータを取得して xml にエクスポートするスクリプトがありますが、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;
?>
Products テーブルの ID に従って在庫結果から数量を取得するには、ヘルプが必要です。
どんな助けでも大歓迎です。