I need to be able to do display data results like so:
namefield name1 name2 name3
addrfield addr1 addr2 addr3
cityfield city1 city2 city3
And then say after 3 result columns, it starts over on a new line repeats the field names and next set of data:
namefield name4 name5 name6
addrfield addr4 addr5 addr6
cityfield city4 city5 city6
Until all the records in the resultset have been displayed. Does that make sense? I'm stuck on this one and have been playing with all sorts of code for hours now.
I came close with this set of code:
$sql="SELECT * FROM mytable order by myrecordnumber ";
$RS=mysql_query($sql);
$result = mysql_query($sql);
$i = 0;
?><table>
<tr>
<? while($row = mysql_fetch_object($result)) { ?>
<td><?=$row->myrecordnumber?></td>
<? $i++ ?>
<? if($i % 3 === 0) { ?>
</tr>
<tr>
<? } ?>
<? } ?>
</table>
Which outputs:
2 4 6
7 8 9
14 15 16
which is great but I need to show more than one field like I demonstrate above (name, address, city, etc) and doing a <tr> messed it all up. Also, I couldn't figure out how to get a table in front of all this to show the data fieldnames (namefield, addrfield, city, etc).
Any tips or advice on how to solve this would be greatly appreciated. Thank you!