Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Stocktrader

macrumors member
Original poster
Oct 28, 2007
85
0
The code below shows results from two queries with the output as:
hotel1
hotel2
hotel3..

count of hotel1
count of hotel2
count of hotel3

How can I get the results to read:
hotel1 count of hotel1
hotel2 count of hotel2
hotel3 count of hotel3

Thanks

.
.
.
while($row = mysql_fetch_array($resultsum)){
echo "Total ". $row['hotel']. " = $". $row['SUM(rate)'];
echo "<br />";
}


while($row = mysql_fetch_array($resultcount)){
echo "There are ". $row['COUNT(rate)'] ." ". $row['rate'] ." items.";
echo "<br />";
}
 

SrWebDeveloper

macrumors 68000
Dec 7, 2007
1,871
3
Alexandria, VA, USA
Please always use PHP BB code tags to wrap source, it's easier for us to follow and assist you. Thanks.

Maybe nobody else has responded because your code does NOT produce the output you posted here. What you want to do is merge some query results into output, which we can gladly help you with. However, this more than likely would be done with the query itself, not just the result set processing. Please post the queries and someone here will be able to assist you better, I think.

On a side note you can assign aliases in your query to fields which then can be used as keys in those associative arrays. This makes for easier debugging and also formats key names properly avoiding potential errors:

PHP:
// $row['SUM(rate)'] could be $row['ratesum'] if the query was: 
$query="select sum(rate) as ratesum from table";
:cool:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.