steveginer Posted November 2, 2006 Share Posted November 2, 2006 hi,does anyone have any hints on how to display query results horizontally as such:result1|result2|result3|result4result5|result6|result7|result8can't figure it out for the life of me.thanks in advance. Link to comment https://forums.phpfreaks.com/topic/25932-displaying-query-results-horizontally/ Share on other sites More sharing options...
Psycho Posted November 2, 2006 Share Posted November 2, 2006 [code]<?php$recordsPerRow = 4;$currentRecord = 0;echo "<table>";while ($record = mysql_fetch_array($results)) { if ($currentRecord == 0) { echo "<tr>"; } echo "<td>" . $record[field] . "</td>"; $currenttRecord++; if ($currentRecord == $recordsPerRow) { echo "</tr>"; $currentRecord = 0; }}if ($currentRecord!=0) { for ($i = $currentRecord; $i<$recordsPerRow; $i++) { echo "<td></td>"; } echo "</tr>";}echo "</table>";?>[code][/code][/code] Link to comment https://forums.phpfreaks.com/topic/25932-displaying-query-results-horizontally/#findComment-118434 Share on other sites More sharing options...
steveginer Posted November 2, 2006 Author Share Posted November 2, 2006 thanks so much. just for anyone else who might reuse this code "$currenttRecord" should be $currentRecord in the code reference here. echo "<td>" . $record[field] . "</td>"; $currenttRecord++;hate to be nag but how would you go about limiting the number of rows displayed per page and then paginate the results. i know this is asking a lot but... Link to comment https://forums.phpfreaks.com/topic/25932-displaying-query-results-horizontally/#findComment-118479 Share on other sites More sharing options...
Psycho Posted November 2, 2006 Share Posted November 2, 2006 Go to the home page of this site and select the tutorials section. There is a pagination tutorial there. Link to comment https://forums.phpfreaks.com/topic/25932-displaying-query-results-horizontally/#findComment-118676 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.