AV1611 Posted December 29, 2006 Share Posted December 29, 2006 I'm doing a simple query. (select single_field from table)I need to display the results in a table with the $row in this order 1 23 45 67etc...the number of returns are up to 26...Not sure how to make the table come out...???Suggestions? Link to comment https://forums.phpfreaks.com/topic/32222-solved-query-return-in-columns/ Share on other sites More sharing options...
trq Posted December 30, 2006 Share Posted December 30, 2006 There is a thread covering this subject in the [url=http://www.phpfreaks.com/forums/index.php/board,41.0.html]FAQ/Snippet Repository[/url]. Link to comment https://forums.phpfreaks.com/topic/32222-solved-query-return-in-columns/#findComment-149597 Share on other sites More sharing options...
chronister Posted December 30, 2006 Share Posted December 30, 2006 [code]<?// query db and get results.... loop through them and add to an array$result_array[]="results from database"$x=0; // set a counter to 0?><table ><?while($x < count($result_array)){?> <tr> <td> <?=$result_array[$x++] ?> </td> <td><?=$result_array[$x++] ?></td> </tr> } ?></table>[/code]This will produce a 2 column table for the results being displayed. Link to comment https://forums.phpfreaks.com/topic/32222-solved-query-return-in-columns/#findComment-149791 Share on other sites More sharing options...
AV1611 Posted December 30, 2006 Author Share Posted December 30, 2006 Brilliant! Stupendously Simple! I feel stupid for not figuring that out myselv :P Link to comment https://forums.phpfreaks.com/topic/32222-solved-query-return-in-columns/#findComment-150110 Share on other sites More sharing options...
chronister Posted December 31, 2006 Share Posted December 31, 2006 I was pretty happy that I came up with that bit of code myself. Its expandable too, just copy/paste the <td>......</td> and it gives you another columnThe other examples are too damn lengthy for me. I see no need to run for loops and calculate what freaking column we are on and all that jazz.....this is simple and to the point.enjoy Link to comment https://forums.phpfreaks.com/topic/32222-solved-query-return-in-columns/#findComment-150201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.