I have two queries that return 5 rows of data from each query. I then merge the resulting arrays to create one array.
If I were using just one arry I would do it like this:
mysql_select_db($database_iMaint, $iMaint);
$query_WaterHot = sprintf("SELECT h.UniqueID, h.Room, h.AuditBy, h.AuditDate, h.SeqID, h.WaterHot
FROM NXLHR_Hist h
WHERE (h.WaterHot IS NOT NULL OR
h.WaterHot IS NOT NULL
)
AND
h.CompStamp >= DATE('".$_POST['FromDate']."')
AND
h.CompStamp <= DATE('".$_POST['ToDate']."')
ORDER BY h.Room ASC
");
$WaterHot = mysql_query($query_WaterHot, $iMaint) or die(mysql_error());
$row_WaterHot = mysql_fetch_assoc($WaterHot);
$totalRows_WaterHot= mysql_num_rows($WaterHot);
do {
echo $row_WaterHot['Room'];
echo $row_WaterHot['WaterHot'];
echo $row_WaterHot['WaterCold'];
} while ($row_WaterHot = mysql_fetch_assoc($WaterHot));
Above is how I would normally process the data but in this case I am using the results from two queries which is why I am merging them.
So I now need to loop through the merged array and output each of the values.
$row_WaterHot = mysql_fetch_assoc($Waterhot); // five records
$row_WaterCold = mysql_fetch_assoc($WaterCold); // five records
$Water = array();
$Water = array_merge($row_WaterHot, $row_WaterCold);
foreach ($Water as $key => $value) {
// how do I echo the results of each value like this
echo "the name of the $key and the $value
}
Or should I be doing this another way?
Thanks in advance for your help and time.