Hi,I have 6 checkboxes.
name,father name,city,state,dob,education

What i am trying
1)if user check name,father name its shows only checked item
name father name
Mr. a Mr.abs
Mr. B Mr.bcd
(table structure like that)

2)if user check name,father name,city its shows only checked item
name father name city
Mr. a Mr.abs abc
Mr. B Mr.bcd def
i.e table structure change acc to check box selection.

What i did.
I gave a table structure but fields which are not selected remain empty.
Need suggestion

<?php session_start();
if (!isset($_SESSION['username']))
header('Location: login.php');

<style type="text/css">
table, th
border:1px solid #666666;

<table width="750px" align="center">
  <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <tr><td><a href="index.php"><img src="images/home.jpg"></a></td>
  <td align="right"><b>Welcome :&nbsp;</b> <?php echo $_SESSION['username']; ?>&nbsp;&nbsp;<a href="logout.php" >Logout</a></td>
  <tr><td align="center"> <strong>Select:</strong>&nbsp;&nbsp;
  <input type="checkbox" name="a[]" value="name">Name
        <input type="checkbox" name="a[]" value="father">Father Name&nbsp;
 <font color="red">City:</font> <select name="users">
        $sql="SELECT DISTINCT city FROM `tbl_hindi`";
        $result =mysql_query($sql);
        while ($data=mysql_fetch_array($result))
        echo "<option value='$data[city]'>$data[city]</option>\n";
        &nbsp;Gender<select name="gender">
        $gen="SELECT DISTINCT gender FROM `tbl_hindi`";
        echo "<option value='$row[gender]'>$row[gender]</option>\n";

        <input type="checkbox" name="a[]" value="address">Address
        <input type="checkbox" name="a[]" value="state">State</td>

        <td align="center">
        <input type="checkbox" name="a[]" value="mobile">Contact
        <input type="checkbox" name="a[]" value="dob">DOB
        <input type="checkbox" name="a[]" value="namdan_date">Namdan date

        <tr><td colspan="2" align="center"><input type="submit" name="submit" value="submit"></td></tr>
$sql = "SELECT";
    $check = (array) $_POST['a'];
    for($i = 0; $i < count($check); $i++) 
        $sql .= ($i == (count($check)-1)) ? " `$check[$i]`" : " `$check[$i]`,";
     $sql .= " from tbl_hindi where city='$city' AND gender='$gender' order by gender desc ,namdan_date desc";
    $result = mysql_query($sql);
    //echo '<br>'.$count.'<br>';
    //$th="<table border=\"1px black solid\";><tr>";
    //for($j=0; $j<$count; $j++)
    //echo $check[$j];
//$result=("SELECT * from tbl_hindi where city='$city'");
//$result = mysql_query("SELECT * from tbl_hindi where city='$city'");
echo "<table border='1' align='center'>
<th colspan='8'>Members Details</th>

while($row = mysql_fetch_array($result))
  echo "<tr>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" . $row['address'] . "</td>";
  echo "<td>" . $row['father'] . "</td>";
  echo "<td>" . $row['state'] . "</td>";
  echo "<td>" . $row['city'] . "</td>";
  echo "<td>" . $row['gender'] . "</td>";
  echo "<td>" . $row['mobile'] . "</td>";
  echo "<td>" . $row['dob'] . "</td>";
  echo "<td>" . $row['namdan_date'] . "</td>";
  echo "</tr>";
echo "</table>";
<div align="center"><a href="javascript:window.print();">Click here to Print</a></div>

What you want to do?You want to format the output?

I only want that table shows acc. to checkbox selection.
Need suggestion.