Note that there are some explanatory texts on larger screens.

plurals
  1. POdisplaying table data from a multidimensional array
    primarykey
    data
    text
    <p>here is my array</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; 1 [1] =&gt; 1 [2] =&gt; 1 [3] =&gt; 1 [4] =&gt; no ) [1] =&gt; Array ( [0] =&gt; 2 [1] =&gt; 2 [2] =&gt; 2 [3] =&gt; 2 [4] =&gt; yes ) [2] =&gt; Array ( [0] =&gt; 3 [1] =&gt; 3 [2] =&gt; 3 [3] =&gt; 3 [4] =&gt; yes ) [3] =&gt; Array ( [0] =&gt; 4 [1] =&gt; 4 [2] =&gt; 4 [3] =&gt; 4 [4] =&gt; no ) [4] =&gt; Array ( [0] =&gt; 5 [1] =&gt; 5 [2] =&gt; 5 [3] =&gt; 5 [4] =&gt; yes ) ) </code></pre> <p>this is what i tried, i'm creating a tables tr portion and what it does is duplicate itself for each record that is being displayed. How else can this be written so that it displays correctly? I know it must be simple i just cant wrap my head around it.</p> <pre><code>&lt;?php $units = json_decode($tablerow); foreach($units as $unit) : for($i=0;$i&lt;=count($unit)-1;$i++) : ?&gt; &lt;tr class="rows"&gt; &lt;td&gt;&lt;input type='text' name='bedroom[]' value='&lt;?=$unit[$i];?&gt;' class='input-small'&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='bath[]' value='&lt;?=$unit[$i];?&gt;' class='input-small'&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='sqrt[]' value='&lt;?=$unit[$i];?&gt;' class='input-small'&gt;&lt;/td&gt; &lt;td&gt;&lt;input type='text' name='price[]' value='&lt;?=$unit[$i];?&gt;' class='input-small'&gt;&lt;/td&gt; &lt;td&gt; &lt;select name='avail[]' class='input-small'&gt; &lt;option value='yes' &lt;?=($unit[$i] == 'yes') ? 'selected="selected' : '';?&gt;&gt;Yes&lt;/option&gt; &lt;option value='no' &lt;?=($unit[$i] == 'no') ? 'selected="selected' : '';?&gt;&gt;No&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td&gt;&lt;button type="button" class="btn btn-danger btn-small removeRow"&gt;remove&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php endfor; endforeach; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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