Location: PHPKode > projects > HypatiaDB > hypatiadb/xhr/addReportCondition.php
<?php
include('../common_db.php');
include('../functions.php');
dbconnect($host, $username, $password);
$strings = loadStrings($lang,'GETDATA');


header("Content-Type: application/xml");

echo('<');?>?xml version="1.0" encoding="UTF-8"?>
<li xmlns="http://www.w3.org/1999/xhtml" id="condition<?php
$report_id = intval($_REQUEST['rid']);
$lvalue = mysql_real_escape_string($_REQUEST['lvalue']);
$rvalue = mysql_real_escape_string($_REQUEST['rvalue']);
$operator = mysql_real_escape_string($_REQUEST['operator']);
$positive = true;
switch($operator) {
	case 'notequal':
		$operator = 'equal';
		$positive = false;
		break;
	case 'lte':
		$operator = 'greaterthan';
		$positive = false;
		break;
	case 'gte':
		$operator = 'lessthan';
		$positive = false;
		break;
	case 'notlike':
		$operator = 'like';
		$positive = false;
		break;
	case 'notrlike':
		$operator = 'rlike';
		$positive = false;
		break;
	case 'notcontains':
		$operator = 'between';
		$positive = false;
		break;
	case 'notbetween':
		$operator = 'contains';
		$positive = false;
		break;
}
//report, lvalue, rvalue, operator, positive
$query = "INSERT INTO report_conditions (report, lvalue, rvalue, operator, positive) VALUES ('$report_id', '$lvalue', '$rvalue', '$operator', '" . ($positive ? '1' : '0') . "')";
mysql_query($query) or print(mysql_error . $query);	//TODO:L10N
$id = mysql_insert_id();
echo($id . '">');	//this is the end of the id

//we also need to pull down the database and table that the
//lvalue references
$query = "SELECT tbl, col FROM report_fields WHERE id = '$lvalue'";

$lvname = mysql_fetch_array(mysql_query($query));


echo("$lvname[tbl].$lvname[col] " . getFriendlyOperator($operator, $positive) . ' ' . $rvalue);

echo(  ' [<span onclick="removeCondition(' . $id . ')" class="ll">' . $strings['GD_REMOVECONDITION'] . ' </span>]');
?></li>
Return current item: HypatiaDB