我有这个代码:
$atrr_row = mysql_query("SELECT * FROM " . DB_PREFIX . "product_attribute WHERE product_id='".$r['product_id']."' and language_id=1");
while($atr=mysql_fetch_array($atrr_row)){
$attr_n_g = mysql_fetch_array(mysql_query("SELECT name FROM " . DB_PREFIX . "attribute_description WHERE attribute_id = '" . $atr['attribute_id'] . "' and language_id=1 LIMIT 1"));
$attr_t.="\t".'<spec name="'.$attr_n_g['name'].'"><![CDATA['.$atr['text'].']]></spec>'."\n";
}
它应该给出来自 2 个表的结果,但它通常首先给出产品信息,然后给出另一个产品的 x2,依此类推,直到所有产品都循环并且结果乘以 x375。
Looped data:
First product:
<specs>
<spec name="Age rating">
<![CDATA[18+]]>
</spec>
<spec name="Release date">
<![CDATA[2012]]>
</spec>
<spec name="Online mode">
<![CDATA[No]]>
</spec>
<spec name="Metacritic score">
<![CDATA[75 - 89]]>
</spec>
</specs>
Second product:
<specs>
<spec name="Age rating">
<![CDATA[18+]]>
</spec>
<spec name="Release date">
<![CDATA[2012]]>
</spec>
<spec name="Online mode">
<![CDATA[No]]>
</spec>
<spec name="Metacritic score">
<![CDATA[75 - 89]]>
</spec>
<spec name="Age rating">
<![CDATA[16+]]>
</spec>
<spec name="Release date">
<![CDATA[2011]]>
</spec>
<spec name="Online mode">
<![CDATA[Yes]]>
</spec>
<spec name="Metacritic score">
<![CDATA[90 - 100]]>
</spec>
</specs>
等等......有什么想法吗?
编辑
产品属性表:http: //i.imgur.com/ROjBQT0.png
属性描述表:http: //i.imgur.com/6M5cNXi.png