Exemplo n.º 1
0
function fetchValue($query)
{
    $res = fetchRow($query);
    if ($res && $res[0]) {
        return $res[0];
    }
}
Exemplo n.º 2
0
function updateArrestee($data, $id = null)
{
    global $db;
    $newdata = $data;
    if ($id) {
        $a = fetchRow("select * from arrestees where id = '" . $db->quote($id) . "'", true);
        foreach ($data as $key => $val) {
            if ($key == 'first_appearance_date_c' && $val != $a['first_appearance_date_c']) {
                $newdata['legal_strategy_c'] = $a['legal_strategy_c'] . "\n" . $a['first_appearance_date_c'] . " - " . $a['next_hearing_time_c'] . ' - ' . $a['first_appearance_location_c'];
            }
            if (in_array($key, array('legal_strategy_c', 'medical_needs_c', 'contacts_c', 'property_issues_c', 'description', 'messages_c'))) {
                if ($val != $a[$key]) {
                    $newdata[$key] = $a[$key] . "\n" . $val;
                }
            }
        }
    }
    dbUpdate('legal_arrestees', $newdata, $id);
}
Exemplo n.º 3
0
<?php

require_once 'config.php';
$db = dbconnect();
$action = $_REQUEST['action'];
$error = "";
$message = "";
if ($action == 'editquery') {
    if ($_POST[query_id] > 1) {
        $fields = fetchRow('select * from queries where query_id=' . $_POST[query_id]);
        $query_id = $fields[0];
        $name = $fields[1];
        $description = $fields[2];
        $query = $fields[3];
    }
    editQuery($name, $description, $query, $query_id);
    exit;
} else {
    if ($action == 'delete') {
        $res = dbQuery('delete from queries where query_id=' . $_GET[query_id]);
        if ($db->affected_rows >= 1) {
            $info = 'Query deleted.';
        } else {
            $error = "Unable to delete query: <br/> {$error}";
        }
    } else {
        if ($action == 'copyquery') {
            $res = dbQuery("insert into queries select null, concat(b.name, '_copy'), b.description, b.query, NOW(), NULL, NULL from queries b where b.query_id = {$_GET['query_id']}");
            if ($res) {
                $info = "Query copied.";
            }
Exemplo n.º 4
0
<table a = "b">
<?php while ($aRow=fetchRow($x)) { ?> <tr> <? foreach($aRow                    as $sId=>$sName) {?> <td><b><?php echo $sId ?></b>:<?php echo $sName ?></b></td>
<?php } ?></tr><?php } ?></table>
<?php if (isset($_POST["text"])) { echo "FOTZEEE"; } else { ?>
<form method="post" action="<? echo $_SERVER["PHP_SELF"]; ?>">
<input type="text" name="text" />
<input type="submit" />
</form>
<? } ?>
Exemplo n.º 5
0
     $query = fetchRow("select query,name from queries where query_id=" . $_REQUEST['query_id']);
     $res = dbQuery($query[0]);
     if ($res) {
         $info = 'Query successfully returned ' . $res->num_rows . ' rows.';
         $output = exportHTML($res, $query[1]);
         //$output = exportTSV($res);
         #$info.= "<pre>".str_replace("\n", '<br/>', $output)."</pre>";
         $res = dbQuery('update queries set executed=NOW() where query_id=' . $_REQUEST[query_id]);
         $executed = fetchItem('select executed from queries where query_id = ' . $_REQUEST[query_id]);
     }
     echo $output;
     echo "error = \"{$error}\"; info=\"{$info}\"; executed=\"" . str_replace(' ', '<br/>', $executed) . "\";";
     exit;
 } else {
     if ($action == 'csv') {
         $query = fetchRow("select query,name from queries where query_id=" . $_REQUEST['query_id']);
         $result = dbQuery($query[0]);
         if ($result) {
             // send response headers to the browser
             header('Content-Type: text/csv');
             header('Content-Disposition: attachment;filename="' . $query[1] . '.csv"');
             $fp = fopen('php://output', 'w');
             $row = $result->fetch_assoc();
             if ($row) {
                 fputcsv($fp, array_keys($row));
             }
             // reset pointer back to beginning
             $result->data_seek(0);
             while ($row = $result->fetch_assoc()) {
                 fputcsv($fp, $row);
             }