title: Displaying data based on checkboxes selection to html table
body: <p>I'm having really hard times displaying data based on multiple checkbox selection into a table..
  I believe the while loop on post2.php might not be the right solution for this..
  What i also have noticed is that the code works when string is posted, but not the array (multiple selection) <code>input type="checkbox" name="pal_num[]"</code> e.g. it works without <code>[]</code>
  Can anybody help please?</p>
  
  <pre><code>&lt;?php
  $l = $_POST['LT'];
  $pals = '';
  
  $r = mysql_query("SELECT DISTINCT pal_num FROM pl_tab WHERE lt_num='$l'");
  
  while ($row = mysql_fetch_assoc($r)) {
      $pals .= '&lt;input type="checkbox" name="pal_num[]" value="'
          . $row['pal_num'] . '"&gt;' . $row['pal_num'] . '&lt;br&gt;';
  }
  
  if ($pal == '') {
      echo '';
  } else {
      echo '&lt;form name="get_pal" action="post2.php" method="POST"&gt;';
      echo $pals;
      echo '&lt;input type="submit" name="post" value="Go!"&gt;';
      echo '&lt;/form&gt;';
  }
  ?&gt;
  </code></pre>
  
  <p><strong>post2.php:</strong></p>
  
  <pre><code>if (isset($_POST['pal_num'])) {
  
      var_dump($_POST);
  //all of 3 options checked
  //array(2) { ["pal_num"]=&gt; array(3) { [0]=&gt; string(3) "111" [1]=&gt; string(3) "222" [2]=&gt; string(3) "333" } ["post"]=&gt; string(3) "Go!" }
  
      mysql_connect(DB_HOST, DB_UNAME, DB_PWD) or die('Database error!!');
      mysql_select_db(DB_NAME);
      echo '&lt;/br&gt;';
      echo "&lt;table border='1'&gt;
      &lt;tr&gt;
          &lt;th width=80 height=25&gt;L num&lt;/th&gt;
          &lt;th width=110 height=25&gt;Descr&lt;/th&gt;
          &lt;th width=90 height=25&gt;Pal num&lt;/th&gt;
          &lt;th width=60 height=25&gt;weight 1&lt;/th&gt;
          &lt;th width=60 height=25&gt;weight 2&lt;/th&gt;
      &lt;/tr&gt;";
  
      $w = $_POST['pal_num'];
      $rrr = mysql_query("SELECT * FROM pl_tab WHERE pal_num='$w'");
  
      var_dump($w);
      //all of 3 options checked
      //array(3) { [0]=&gt; string(3) "111" [1]=&gt; string(3) "222" [2]=&gt; string(3) "333" }
  
      while ($row = mysql_fetch_array($rrr)) {
          echo '&lt;tr&gt;&lt;td&gt;' . '&amp;nbsp' . '&lt;/td&gt;';
          echo '&lt;td rowspan="5"&gt;' . $row['descr'] . '&lt;/td&gt;';
          echo '&lt;td&gt;&lt;b&gt;' . 'Total weight' . '&lt;b&gt;&lt;/td&gt;';
          echo '&lt;td&gt;' . '&amp;nbsp' . '&lt;/td&gt;&lt;td&gt;' . '&amp;nbsp' . '&lt;/td&gt;&lt;/tr&gt;';
  
          echo '&lt;td&gt;' . '&amp;nbsp' . '&lt;/td&gt;';
          echo '&lt;td colspan="3"&gt;' . '&amp;nbsp' . '&lt;/td&gt;';
  
          echo '&lt;tr&gt;&lt;td&gt;' . $row['l_num'] . '&lt;/td&gt;';
          echo '&lt;td&gt;' . $row['pal_num'] . '&lt;/td&gt;';
          echo '&lt;td&gt;' . $row['weight 1'] . '&lt;/td&gt;&lt;td&gt;'
              . $row['weight 2'] . '&lt;/td&gt;&lt;/tr&gt;';
      }
      echo "&lt;/table&gt;";
  }
  </code></pre>