title: How to get the checkboxes value in checked order in php
body: <p>In the registration part there will be some images and it will shuffle automatically in each refresh. user should select one or more images (tick the corresponding checkboxes) and it will stored in database instead of password.It will work correctly and problem is in login page.I want the values of checkboxes in checked order. that means if I checked second checkbox and then first box,then value will get the same order.</p>
  
  <p>here is the code</p>
  
  <pre><code>&lt;?php
  include("config.php");
  if(isset($_POST['s'])){
  $username=$_POST['username'];
  if(isset($_POST['chk1']))
  {
   $t1=implode(',', $_POST['chk1']);
  }
  echo $t1;
  $query=mysql_query("select *from register where username='$username' and password='$t1'");
  $res=mysql_num_rows($query);
  if($res&gt;0)
  {
  session_start();
  $_SESSION['usr']=$username;
  header("location:userhome.php");
  }
  else
  {
   echo mysql_error();
   }
   }
   ?&gt;
  
  &lt;body&gt;
  &lt;form action="" method="post"&gt;
  &lt;table width="200" border="0"&gt;
  &lt;th colspan="2" scope="row"&gt;&lt;a href="register.php"&gt;
  &lt;font color="#FF0000"&gt;New Registration&lt;/font&gt;      &lt;/a&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th scope="row"&gt;Username&lt;/th&gt;
  &lt;td&gt;&lt;label for="username"&gt;&lt;/label&gt;
  &lt;input type="text" name="username" id="username" /&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th colspan="2" scope="row"&gt;&lt;u&gt;Choose Password&lt;/u&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;th scope="row"&gt;&amp;nbsp;&lt;/th&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;div align="center"&gt;
  &lt;?php
  $images = array(
  '&lt;input name="chk1[]" type="checkbox" value="1" /&gt;
  &lt;img src="images/images (4).jpg" alt="" width="234" height="212" /&gt;',
  '&lt;input name="chk1[]" type="checkbox" value="2"  /&gt;
  &lt;img src="images/images (6).jpg" alt="" width="234" height="212" /&gt;',
  '&lt;input name="chk1[]" type="checkbox" value="3" /&gt;
  &lt;img src="images/images (5).jpg" alt="" width="234" height="212" /&gt;', 
  '&lt;input name="chk1[]" type="checkbox" value="4" /&gt;
   &lt;img src="images/drt.jpg" alt="" width="234" height="212" /&gt;',
  '&lt;input name="chk1[]"   type="checkbox" value="5" /&gt;
   &lt;img src="images/rf.jpg" alt="" width="234" height="212" /&gt;',
  '&lt;input name="chk1[]" type="checkbox" value="6" /&gt;
  &lt;img src="images/yu.jpg" alt="" width="234" height="212" /&gt;', 
  '&lt;input name="chk1[]" type="checkbox" value="7" /&gt;
   &lt;img src="images/ed.jpg" alt="" width="234" height="212" /&gt;'
    );
  shuffle($images); // Randomize images array;
  echo $images[0];
  echo $images[1];
  echo $images[2];
  echo $images[3];
  echo $images[4];
  echo $images[5];
  echo $images[6];
  ?&gt;
  </code></pre>
  
  <p><br /><br/>
     
     </p>