Ejemplo n.º 1
0
<?php

/**
 * Processes incoming POST requests and updates the rainout table
 */
require 'vendor/autoload.php';
require 'db_config.php';
require 'models/rainouts.php';
$rainoutModel = new Rainout($db);
// Take a look at all our incoming data
$ids_raw = $_POST['id'];
$weeks_raw = $_POST['week'];
$descriptions_raw = $_POST['description'];
// Filter out bad values
$ids = [];
$weeks = [];
$descriptions = [];
foreach ($ids_raw as $id) {
    $ids[] = filter_var($id, FILTER_SANITIZE_STRING);
}
foreach ($weeks_raw as $week) {
    $weeks[] = filter_var($week, FILTER_SANITIZE_NUMBER_INT);
}
foreach ($descriptions_raw as $description) {
    $descriptions[] = filter_var($description, FILTER_SANITIZE_STRING);
}
$new_week = filter_var($_POST['new_week'], FILTER_SANITIZE_NUMBER_INT);
$new_description = filter_var($_POST['new_description'], FILTER_SANITIZE_STRING);
// First, let's update any existing rainouts
foreach ($descriptions as $key => $description) {
    $rainoutModel->update($ids[$key], $weeks[$key], $description);
Ejemplo n.º 2
0
<?php

use Pagerfanta\Adapter\ArrayAdapter;
use Pagerfanta\Pagerfanta;
require 'vendor/autoload.php';
require 'db_config.php';
require 'models/rainouts.php';
// Find out page
$current_page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_NUMBER_INT);
if ($current_page == 0) {
    $current_page = 1;
}
$rainoutModel = new Rainout($db);
$rainouts = $rainoutModel->getAll();
$adapter = new ArrayAdapter($rainouts);
$pagerfanta = new Pagerfanta($adapter);
$pagerfanta->setCurrentPage($current_page);
$nb_results = $pagerfanta->getNbResults();
$current_page_results = $pagerfanta->getCurrentPageResults();
// Display rainout form with data
require 'templates/rainouts/index.php';