I need some help with a looping problem. For my example code below, I have two Mysql tables:
tblDepRatesCats:
ID
header
left_text
center_text
right_text
header_order
------
tblRates_balance:
id
depratecat
MinBalance
InterestRate
APY
suborder
The tblDepRatesCats.ID = tblRatesBalance.depratecat. For each row in tblDepRatesCats, there may be 0 or 1 or more rows in tblRates_balance.
I'm trying to display the results of querying these tables so that it shows each tblDepRatesCats data with the corresponding tblRates_balance data, but instead it is showing tblDepRatesCats so that if tblDepRatesCats row has 3 tblDepRatesCats rows associted with it, the tblDepRatesCats row is repeated 3 times with one row of tblDepRatesCats'
As you can see below "Super Now Checking Account" is displayed 3 times, but what I want is for it to display just once with the 3 results for minimum balance and apy listed under the one header.
NOW Checking Accounts Minimum Daily Balance to Earn APY Annual Percentage Yield $1000 10
Super NOW Checking Account Minimum Daily Balance to Earn APY Annual Percentage Yield % $2222 2
Super NOW Checking Account Minimum Daily Balance to Earn APY Annual Percentage Yield % $2100 25
Super NOW Checking Account Minimum Daily Balance to Earn APY Annual Percentage Yield % $2000 20
Money Market Accounts Minimum Daily Balance to Earn APY Annual Percentage Yield % $3000 30
Below is my test code. Any help would be greatly appreciated.
$result = mysql_query('SELECT tblDepRatesCats.*, tblRates_balance.* FROM tblDepRatesCats JOIN tblRates_balance ON tblDepRatesCats.ID = tblRates_balance.depratecat ORDER BY tblDepRatesCats.header_order, tblRates_balance.suborder;');
while ($row = mysql_fetch_assoc($result))
{
echo ("<table width=\"98%\" border=\"0\" bgcolor:\"#ffffff\"><tr><td>");
echo ("" . $row["header"] . " <br>");
echo ("" . $row["left_text"] . " ");
echo ("" . $row["right_text"] . "");
echo ("</tr></td>");
//   temporarily added
echo ("<tr><td>");
echo ("" . $row["MinBalance"] . "");
echo (" ");
echo ("" . $row["InterestRate"] . " <br><br>");
echo ("</tr></td>");
}