any idea why this behaves unexpectedly????...
<?
$sHost = "localhost";
$sUser = "*****";
$sPass = "*****";
mysql_connect($sHost,$sUser,$sPass);
mysql_select_db("*****"
$combined = mysql_query("SELECT combocode, combotitle, combodesc, comboimage FROM combined WHERE combined.combocode = 1"
$product = mysql_query("SELECT title, description , material , colours FROM product WHERE product.combocode = 1"
$prices = mysql_query("SELECT price FROM product, details WHERE product.combocode = 1 AND details.productID = product.productID"
$sizes = mysql_query("SELECT sizes FROM product, size WHERE product.combocode = 1 AND product.sizeID = size.sizeID"
while($combinedRow = mysql_fetch_assoc ($combined)){
listRow($combinedRow);
while($productRow = mysql_fetch_assoc($product)){
listRow($productRow);
while($pricesRow = mysql_fetch_assoc($prices)){
listRow($pricesRow);
while($sizesRow = mysql_fetch_assoc($sizes)){
listRow($sizesRow);
}
}
}
}
function listRow($row){
foreach ($row as $key => $value) {
$hold = strtoupper("<$key>"
$hold .= $value;
$hold .= strtoupper("</$key>"."\n";
}
echo $hold;
}
?>
///////////////////////////////////////////////////////////////////
produces the output...
<COLOURS>pink, black, blue</COLOURS>
<COMBOCODE>4</COMBOCODE>
<PRICE>22.99</PRICE>
<SIZES>one size</SIZES>
<SIZES>32, 36, 38, 40</SIZES>
<PRICE>9.99</PRICE>
<COLOURS>red</COLOURS>
there is missing information, like all the info from the table 'combined' bar the 'combocode' field.
However, if i exchange the 'listRow' function for this(+ make appropriate changes to calling functions)...
///////////////////////////////////////////
function listRow($query, $row){
if(!mysql_num_rows($query)) {
return "EMPTY";
} else {
$iNumFields = mysql_num_fields($query);
$iNumRes = mysql_num_rows($query);
while($iRow = mysql_fetch_array($query)) {
$sRet = " <RESULT>\n";
for($a = 0; $a < $iNumFields; $a++) {
$sTmp = mysql_field_name($query,$a);
$sRet .= " ".strtoupper("<$sTmp>"
$sRet .= $iRow["$sTmp"];
$sRet .= strtoupper("</$sTmp>"."\n";
}
$sRet .= " </RESULT>\n";
}
}
echo $sRet;
}
///////////////////////////////////////////////
i get the output...
<RESULT>
<PRODUCTID>1</PRODUCTID>
<TITLE>tits</TITLE>
<DESCRIPTION>false large tits</DESCRIPTION>
<MATERIAL>rubber</MATERIAL>
<COLOURS>red</COLOURS>
</RESULT>
<RESULT>
<PRICE>9.99</PRICE>
</RESULT>
<RESULT>
<SIZES>32, 36, 38, 40</SIZES>
</RESULT>
...any ideas, i am very confused.
thanks, ben.