Note that there are some explanatory texts on larger screens.

plurals
  1. POComplex multidimensional loop into a table
    text
    copied!<p>I have a problem populating a table from a complex loop.</p> <p>The table is composed of 7 days calendar table and each day should contain the day events under it.</p> <pre><code>Array ( [2012-12-16] =&gt; Array ( ) [2012-12-17] =&gt; Array ( [0] =&gt; Array ( [date] =&gt; 2012-12-17 [time_booked] =&gt; 00:09:00 [time_start] =&gt; 00:00:00 [time_end] =&gt; 00:00:00 [name] =&gt; maha mostafa elrashed [first_name] =&gt; marwan [title] =&gt; root cannal ) [1] =&gt; Array ( [date] =&gt; 2012-12-17 [time_booked] =&gt; 09:00:00 [time_start] =&gt; 00:00:00 [time_end] =&gt; 00:00:00 [name] =&gt; demo demo eldemo [first_name] =&gt; marwan [title] =&gt; ultrasound ) ) [2012-12-18] =&gt; Array ( [0] =&gt; Array ( [date] =&gt; 2012-12-18 [time_booked] =&gt; 09:00:00 [time_start] =&gt; 00:00:00 [time_end] =&gt; 00:00:00 [name] =&gt; demo demo eldemo [first_name] =&gt; marwan [title] =&gt; root cannal ) ) [2012-12-19] =&gt; Array ( ) [2012-12-20] =&gt; Array ( ) [2012-12-21] =&gt; Array ( ) [2012-12-22] =&gt; Array ( ) ) </code></pre> <p>This example of array I want to convert into a table. currently I find the easiest way is to print each <strong>day as ul and float left them</strong>, but what I really want is to make a table out of them to be able to sort that table using jQuery in future.</p> <pre><code>foreach($ztable as $t){ echo"\n&lt;ul style='float:left;width:140px'&gt;"; foreach($t as $r){ echo "&lt;li class='{$r['first_name']}'&gt;{$r['name']}&lt;/li&gt;"; } echo "&lt;/ul&gt;\n"; } </code></pre> <p>Any suggestions? I'm using Codeigniter 2 by the way</p> <p>Edit:</p> <p><img src="https://i.stack.imgur.com/ECt6b.jpg" alt="top table is from the suggested answer, the lower one is how I want it to be"></p> <p>Top table is from the suggested answer, the lower one is how I want it to be.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload