Nodral Posted April 21, 2011 Share Posted April 21, 2011 Hi All Please see code below. I cannot get my table to produce correctly. I have a multidimensional array $data['id']['fieldid']=$row['content'] I want this to loop through and create a new line in a table for each sub-array. hence the table would look like this. (id1 in this row) field1 content field2 content field3 content field4 content (id2 in this row) field1 content field2 content field3 content field4 content (id3 in this row) field1 content field2 content field3 content field4 content (id4in this row) field1 content field2 content field3 content field4 content etc etc. The table can grow or shrink depending on the data I'm retrieving. <table><font size="8"> <tr> <?php foreach ($header_out as $value){ echo "<td>$value</td>"; } ?> </tr> <?php echo"<tr>"; foreach($data as $value){ $count++; foreach($value as $dataout){ echo "<td>$dataout $count</td>"; } }echo"</tr><tr>"; ?> </tr></font></table> <?php } ?> The header section works fine, but the double foreach loop seems to be where I'm failing. Any advice guys? Quote Link to comment https://forums.phpfreaks.com/topic/234338-foreach-into-table/ Share on other sites More sharing options...
Nodral Posted April 21, 2011 Author Share Posted April 21, 2011 Need to bump this as I need an answer please!!! I'm stuck on the last part of a huge extract script. Quote Link to comment https://forums.phpfreaks.com/topic/234338-foreach-into-table/#findComment-1204500 Share on other sites More sharing options...
Muddy_Funster Posted April 21, 2011 Share Posted April 21, 2011 what is the EXACT problem? what are you getting out that you are not expecting and what are you expecting that you are not getting out? Quote Link to comment https://forums.phpfreaks.com/topic/234338-foreach-into-table/#findComment-1204504 Share on other sites More sharing options...
Nodral Posted April 21, 2011 Author Share Posted April 21, 2011 I seem to be able to either get all the content in column 1 of the table or all in 1 row for all id's. I want each id on it's own line in the table. I just don't seem to be able to get the <tr> tags to appear in the correct place when foreaching the info out. Quote Link to comment https://forums.phpfreaks.com/topic/234338-foreach-into-table/#findComment-1204508 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.