选中多个复选框时,页面会中断

I have a page with some checkboxes on and which works fine if just one checkbox is selected, however if I select 2 or more checkboxes the results show fine but the rest of the page after the script cuts off. any ideas what would cause this to happen.

<?php

if (isset($_POST['criteria']) && !empty($_POST['criteria'])) {
    foreach($_POST['criteria'] as $key => $value) {

        // get the function

        include ($_SERVER['DOCUMENT_ROOT'] . '/scripts/pagination-functions.php');

        $page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
        $limit = 14;
        $startpoint = ($page * $limit) - $limit;

        // Runs mysql_real_escape_string() on every value encountered.

        $clean_criteria = array_map('mysql_real_escape_string', $_REQUEST['criteria']);

        // Convert the array into a string.

        $criteria = implode("','", $clean_criteria);

        // to make pagination

        $statement = "table WHERE page IN ('$criteria') ORDER BY long_title ASC";
        if (!$query = mysql_query("SELECT * FROM {$statement} LIMIT {$startpoint} , {$limit}")) {
            echo "Cannot parse query";
        }
        elseif (mysql_num_rows($query) == 0) {
            echo "No records found";
        }
        else {
            echo "";
            while ($row = mysql_fetch_assoc($query)) {
                echo "" . $row['name'] . "<br />
             " . $row['description'] . "";
            }
        }

        echo "<div class=\"pagination\">";
        echo pagination($statement, $limit, $page);
        echo "</div>";
    }
}

?>

If anyone can help or point in the right direction I would be very greatful

Are you sure you want to have everything sitting inside that foreach loop? It looks like you don't need to have that foreach loop in there at all because you're using the criteria items as a group, not individually:

$clean_criteria = array_map('mysql_real_escape_string', $_REQUEST['criteria']);
$criteria = implode("','", $clean_criteria);

This means that your query will be executed once for every single criteria specified, but every query already looks at all the criteria. You never reference either $key or $value, so I don't think the loop is useful.

Reworked code example

<?php

if (!empty($_POST['criteria'])) {

    // get the function

    include ($_SERVER['DOCUMENT_ROOT'] . '/scripts/pagination-functions.php');

    $page = (int)(!isset($_GET["page"]) ? 1 : $_GET["page"]);
    $limit = 14;
    $startpoint = ($page * $limit) - $limit;

    // Runs mysql_real_escape_string() on every value encountered.

    $clean_criteria = array_map('mysql_real_escape_string', $_POST['criteria']);

    // Convert the array into a string.

    $criteria = implode("','", $clean_criteria);

    // to make pagination

    $statement = "table WHERE page IN ('$criteria') ORDER BY long_title ASC";
    $query = mysql_query("SELECT * FROM {$statement} LIMIT {$startpoint} , {$limit}");
    if (!$query) {
        echo "Cannot parse query";
    } elseif (mysql_num_rows($query) == 0) {
        echo "No records found";
    } else {
        while ($row = mysql_fetch_assoc($query)) {
            echo $row['name'] . "<br />" . $row['description'] . "<br /><br />";
        }
    }

    echo "<div class=\"pagination\">";
    echo pagination($statement, $limit, $page);
    echo "</div>";
}
?>