Ahh . . . yeah I see . . . well this many not be possible to get these in rows like this without duplicate values in one or the other, I'll explain why. This one set the stage so to speak, so I followed . . .
I am trying to populate a html table via 2 queries from 2 different sql tables.
What you have here are two different tables, and I mean in terms of the way they'd display, not the database tables themselves. I don't think you'll ever get a joined row that belongs on the same row without duplicates.
True they have a common field to join on, you can see that, but the data from the two tables does not intersect, it doesn't belong in the same row
unless the data is related in some other way. For example, for each paycheck there is an expense related to that paycheck.
Here is **why** it's happening. Let's take a simplified example.
credits
UserID|credit|amount
1234|paycheck|50
UserID|expenses|anount
1234|gas|200
1234|gum|100
1234|dog food|50
So this will indeed generate three rows, because, well, there are three matching records in the join:
select * from table where tablea.UserID=tableb.UserID
1234|paycheck|50|1234|gas|200
1234|paycheck|50|1234|gum|100
1234|paycheck|50|1234|dog food|50
The problem will inverse itself if you have say, 3 records in the first table an one in the second.
What you can do, if this is more or less doing what you want except for the duplicates, is only print the values if they are not the same as the previous.
$col_1 = ($col_1!=$row[0])?$row[0]:' ';
$col_2 = ($col_2!=$row[1])?$row[1]:' ';
$col_3 = ($col_3!=$row[2])?$row[2]:' ';
echo "<td>$col_1</td><td>$col_2</td><td>$col_3</td>";
Kind of a home grown way to do it, but in cases like this you might have to resort to that, in order to get varying numbers of records for the same day in one set of rows.