title: get and display multiple checkbox values from database using php
body: <p>i having two check boxes when i am selecting both check boxes i want to show the value related to both from database ,but now i able to print only one id of check boxes i want to show both data can anyone help hoe to show both a value ,Below is my code:</p>
  
  <p>html</p>
  
  <pre><code> &lt;input type="submit" name="Update" src="/image/exporttt.png" style="margin:0px;cursor:pointer"&gt;
  
  &lt;tbody&gt;
  &lt;?php
  
  $clientid=$_GET['clientid'];
  
  if($clientid!=""){
  
  $sql = mysql_query("SELECT * FROM clientnetworkpricehistory");
  
  
  while($rows=mysql_fetch_array($sql))
  {
  if($alt == 1)
          {
             echo '&lt;tr class="alt"&gt;';
             $alt = 0;
          }
          else
          {
             echo '&lt;tr&gt;';
             $alt = 1;
          }
  
  echo ' 
          &lt;td id="CPH_GridView1_clientid" style="width:140px" class=" clientid '.$rows["net_id"].'"&gt;'.$rows["clientid"].'&lt;/td&gt;
          &lt;td id="CPH_GridView1_country" style="width:160px" class=" country '.$rows['net_id'].'"&gt;'.$rows["country"].'&lt;/td&gt;       
          &lt;td id="CPH_GridView1_networkname" style="width:156px" class="networkname '.$rows["net_id"].'"&gt;'.$rows["networkname"].'&lt;/td&gt;
          &lt;td id="CPH_GridView1_mccmnc" style="width:250px" class=" mcc'.$rows["net_id"].'"&gt;'.$rows["mcc"].'&lt;/td&gt; 
          &lt;td id="CPH_GridView1_mccmnc" style="width:250px" class=" mnc '.$rows["net_id"].'"&gt;'.$rows["mnc"].'&lt;/td&gt;         
          &lt;td id="CPH_GridView1_oldprice" style="width:320px" class=" oldprice '.$rows["net_id"].'"&gt;'.$rows["pricefrom"].'&lt;/td&gt;
          &lt;td id="CPH_GridView1_newprice" style="width:129px" class=" newprice '.$rows["net_id"].'"&gt;'.$rows["priceto"].'&lt;/td&gt; 
          &lt;td id="CPH_GridView1_oldroute" style="width:143px" class="oldsupplierroute '.$rows["net_id"].'"&gt;'.$rows["routefrom"].'&lt;/td&gt;    
          &lt;td id="CPH_GridView1_newroute" style="width:143px" class=" newsupplierroute '.$rows["net_id"].'"&gt;'.$rows["routeto"].'&lt;/td&gt;     
          &lt;td id="CPH_GridView1_comments" style="width:143px" class=" comments '.$rows["net_id"].'"&gt;'.$rows["status"].'&lt;/td&gt;      
          &lt;td id="CPH_GridView1_from" style="width:143px" class=" fromdate '.$rows["net_id"].'"&gt;'.date('d.m.Y H:i', $rows["datetime"]).'&lt;/td&gt;         
  
          &lt;td style="width:65px" class=" '.$rows["net_id"].'"&gt;&lt;input type="checkbox" name="chk1" value=" '.$rows["net_id"].'"/&gt;&lt;/td&gt;
  
          &lt;/tr&gt;';
  }
  }
  ?&gt;
  
  &lt;/tbody&gt;
  </code></pre>
  
  <p>jssearch.php</p>
  
  <pre><code>&lt;?php
   //connecting to db     
  $variable=$_POST['chk1'];
  foreach ($variable as $variablename)
  {
  $sql_select="SELECT * from clientnetworkpricehistory where net_id=$variablename";
  $queryRes = mysql_query($sql_select);
  print"$sql_select";
  }
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;country&lt;/th&gt;
  &lt;th&gt;networkname &lt;/th&gt;
  &lt;th&gt;mcc&lt;/th&gt;
  &lt;th&gt;mnc&lt;/th&gt; 
          &lt;th&gt;datetime &lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysql_fetch_array($queryRes))
  {
  echo "&lt;tr&gt;";
  echo "&lt;td&gt;" . $row['country'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['networkname'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['mcc'] . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row['mnc'] . "&lt;/td&gt;"; 
  echo "&lt;td&gt;" . $row['datetime'] . "&lt;/td&gt;"; 
  echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  ?&gt; 
  </code></pre>
  
  <p>my out put was(i am checked two checkboxes and i am trying to print two check boxes id it only showing one can any one help me how to do that)</p>
  
  <pre><code>56
  Warning: Invalid argument supplied for foreach()
  </code></pre>