Esempio n. 1
0
    <body>
        <?php 
include_once './db-connect.php';
include './sortform.php';
include './searchform.php';
$action = filter_input(INPUT_GET, 'action');
//sorting variables
$sortvalue = filter_input(INPUT_GET, 'sorting');
$columnselect = filter_input(INPUT_GET, 'column');
//searching variables
$searchcolumn = filter_input(INPUT_GET, 'searchcolumn');
$search = filter_input(INPUT_GET, 'search');
//if statement determines which function to use
if ($action == "sort") {
    //uses sort function
    $results = sortcorps($columnselect, $sortvalue);
} else {
    if ($action == "search") {
        //uses search function
        $results = searchcorps($searchcolumn, $search);
    } else {
        if (!isset($action)) {
            $db = getDatabase();
            $stmt = $db->prepare("SELECT * FROM corps");
            $results = array();
            if ($stmt->execute() && $stmt->rowCount() > 0) {
                $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
            }
        }
    }
}
Esempio n. 2
0
    <body>
        <?php 
include_once './dbconnect.php';
include './form1.php';
include './form2.php';
$action = filter_input(INPUT_GET, 'action');
//form 2 variables
$dropsel2 = filter_input(INPUT_GET, 'groupby');
$search = filter_input(INPUT_GET, 'search');
//form 1 variables
$dropsel = filter_input(INPUT_GET, 'columns');
$radiosel = filter_input(INPUT_GET, 'sorting');
//if statements to determine which option was selected
if ($action == "sort") {
    //connect and use sort function
    $results = sortcorps($dropsel, $radiosel);
} else {
    if ($action == "search") {
        //connect and use search function
        $results = searchcorps($dropsel2, $search);
    } else {
        if (!isset($action)) {
            //default database connection
            $db = dbconnect();
            $stmt = $db->prepare("SELECT * FROM corps");
            $results = array();
            if ($stmt->execute() && $stmt->rowCount() > 0) {
                $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
                echo "Rows Found: " . $stmt->rowCount();
            }
        }