Ejemplo n.º 1
0
    if ($added == 'Yesterday') {
        $start -= 60 * 60 * 24;
    }
    $end = $start + 60 * 60 * 24;
    $where = addWhere($where, "(message.added>={$start} AND message.added<{$end})");
}
if ($action !== 'All') {
    $where = addWhere($where, '(message.action=\'' . $action . '\')');
}
if ($new !== 'All') {
    $where = addWhere($where, '(message.showCount' . $new . ')');
}
if ($search !== '') {
    $where = addWhere($where, '(messages.contents MATCH \'' . $search . '\')');
}
$where = addWhere($where, '(message.deleted=0)');
//display the contents
$sql = 'SELECT messages.contents, message.action, message.id, message.added, message.showCount, message.readCount FROM messages INNER JOIN message on messages.rowId=message.messageId ' . $where . ' ORDER BY message.added DESC';
$result = $db->query($sql);
$index = 0;
foreach ($result as $row) {
    //I don't think there's a way to get how many rows are returned from a SQLite query, and I'm too
    //lazy to find out, so simply only write out the table if we have data to output
    if (!$index) {
        echo $resultTableHeader;
    }
    $shownIds[$index]['showCount'] = $row['showCount'];
    $shownIds[$index]['id'] = $row['id'];
    $index++;
    $addDate = gmdate("Y-m-d", $row['added']);
    $addTime = gmdate("H:i:s", $row['added']);
Ejemplo n.º 2
0
    if ($where) {
        if ($and) {
            $where .= " AND {$add}";
        } else {
            $where .= " OR {$add}";
        }
    } else {
        $where = $add;
    }
    return $where;
}
if (!empty($_POST["filter"])) {
    $where = "";
    if ($_POST["price_start"]) {
        $where = addWhere($where, "`price` >= '" . htmlspecialchars($_POST["price_start"])) . "'";
    }
    if ($_POST["price_end"]) {
        $where = addWhere($where, "`price` <= '" . htmlspecialchars($_POST["price_end"])) . "'";
    }
    if ($_POST["manufacturers"]) {
        $where = addWhere($where, "`manufacturer` IN (" . htmlspecialchars(implode(",", $_POST["manufacturers"])) . ")");
    }
    if ($_POST["wifi"]) {
        $where = addWhere($where, "`wifi` = '1'");
    }
    $sql = "SELECT * FROM `my_table`";
    if ($where) {
        $sql .= " WHERE {$where}";
    }
    echo $sql;
}