I would like to display results from the database based on values of checked boxes. Any ideas?
<p>This is part2 of my original question here:</p>

<p><a href="http://stackoverflow.com/questions/15390597/any-ideas-why-results-of-query-are-not-being-displayed-as-checkboxes">Any ideas why results of query are not being displayed as Checkboxes?</a></p>

<p>The user is presented with checkboxes with values.</p>

<p>We would like to see results displayed based on checkedboxes.</p>

<p>If a user checks one box, values associated with that checkbox is displayed.</p>

<p>Similarly, if a user checks more than one checked boxes, values of the checked boxes are displayed in coma-delimited fashion.</p>

<p>The checkbox markup has been implelemented successfully.</p>

<p>The code works fine and is shown below:</p>

<pre><code> &lt;form name ="checkForm" method="post" action="Search.php"&gt;
  &lt;input type="checkbox" name="ckform1"
        onClick="checkAll(this.form,this)"&gt;Check/Uncheck All
        &lt;br&gt;
&lt;?php

   // Connect to SQL Server database
   include("../dbConnect.php");


   // Construct query
     $sql = "SELECT * FROM Search WHERE resultType IS NOT NULL";

// Execute query
$stmt = sqlsrv_query( $conn, $sql);
if( $stmt === false )
{
     echo "Error in executing query.&lt;/br&gt;";
     die( print_r( sqlsrv_errors(), true));
}

  while($row = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC)){
  echo '&lt;input type="checkbox" name="ck[]"
  value="'.$row["resultType"].'"&gt;&lt;font class=heading&gt;'.$row["resultType"].'&lt;/font&gt;&lt;br&gt;';
  }
  // Free statement and connection resources
  sqlsrv_free_stmt($stmt);
  sqlsrv_close($conn);
  ?&gt;
  &lt;P&gt;&lt;input type="submit" value="Go"&gt;
  &lt;/form&gt;
</code></pre>

<p>Right now, I am having difficult with Search.php.</p>

<p>This is the file that should return values based on checked checkbox or checked checkboxes.</p>

<p>So far, I am not getting an error. Instead, I am getting a blank screen.</p>

<p>Thanks for your assistance </p>

<pre><code>&lt;?php

 $ckList = format($_GET["ck"]);

// Connect to SQL Server database
include("../dbConnect.php");


   if ( isset($_POST) &amp;&amp; isset($_POST['Search']) )
    {
    $resultTypeWhereClause = '';

    if ( ! empty($_POST['ckList']) ) // if the ckoptions var is set, we'll add the values to the query
    {
        $optionsToSearch = is_array($_POST['ckList']) ? $_POST['ckList'] : array($_POST['ckList']);
        foreach ( $optionsToSearch as &amp;$ckval )
        {
                // prevent sql injection
            $ckval = mysql_real_escape_string($ckval);
        }
        // add all values to an 'IN' clause
        $resultTypeWhereClause = "resultType IN ('" . implode("', '", $optionsToSearch) . "')";
    }

    if ( empty($resultTypeWhereClause) )
    {
        $resultTypeWhereClause = '1';
    }

    $found = array();
    // build the final query
    $sql = 'SELECT * FROM Search WHERE ' .$resultTypeWhereClause;

    // Execute query
    $stmt = sqlsrv_query( $conn, $tsql);
    if( $stmt === false )
    {
     echo "Error in executing query.&lt;/br&gt;";
     die( print_r( sqlsrv_errors(), true));
    }
    $results = array();

// Retrieve and display the results of the query
$lastresultType = "";
while($row = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC)) {
    array_push($results,$row);
}

 echo json_encode($results);

// Free statement and connection resources
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
   }
 ?&gt;
</code></pre>
