Example #1
0
function addTagAndReturn($label)
{
	if(!ctype_digit($label) && $label != "")
	{
		$d = mysql_num_rows(@mysql_query("SELECT id FROM tags WHERE label = '" . changeChars($label) . "'"));
		if($d == 0) {
			mysql_query("INSERT INTO tags (label) VALUES ('" . changeChars($label) . "')");
			$r = mysql_fetch_array(@mysql_query("SELECT id FROM tags WHERE label = '" . $label . "'"));
			return $r['id'];
		}
	}
	else
	{
		return $label;
	}
}
Example #2
0
{
	$dateData = strtotime($_POST['date']);
	$timeData = strtotime($_POST['time']);
	
	$date = date("Y-m-d", $dateData) . " " . date("H:i:s", $timeData);
	
	// Check that the values are ok
	$value1 = mysql_fetch_array(mysql_query("SELECT SUM(price) AS total FROM items WHERE accountId = '" . $_POST['fromAccount'] . "'", $dbh));
	$acct1 = mysql_fetch_array(mysql_query("SELECT label FROM accounts WHERE id = '" . $_POST['fromAccount'] . "'", $dbh));
	$acct2 = mysql_fetch_array(mysql_query("SELECT label FROM accounts WHERE id = '" . $_POST['toAccount'] . "'", $dbh));
	
	if($value1['total'] >= $_POST['amount'])
	{
		$b = "INSERT INTO items (showacc, accountId, quantity, price, date, item, priceFormatId, remarks, mode, placeId, tagIds) VALUES ('0', '" . $_POST['fromAccount'] . "', '1', '" . (-1 * $_POST['amount']) . "', '" . $date . "', '" . changeChars($acct1['label']) . " ⇒ " . changeChars($acct2['label']) . "', '1', '" . changeChars($_POST['remarks']) . "', 'transfer', '1', '71')";
		mysql_query($b, $dbh);
		$d = "INSERT INTO items (showacc, accountId, quantity, price, date, item, priceFormatId, remarks, mode, placeId, tagIds) VALUES ('1', '" . $_POST['toAccount'] . "', '1', '" . ($_POST['amount']) . "', '" . $date . "', '" . changeChars($acct1['label']) . " ⇒ " . changeChars($acct2['label']) . "', '1', '" . changeChars($_POST['remarks']) . "', 'transfer', '1', '71')";
		mysql_query($d, $dbh);
	}
	else
	{
		$msg = "Cannot Transfer. You cannot exceed the amount in that account.";
		$color = "#ffcc00";
	}
	
	if(mysql_affected_rows($dbh) > 0) { 
		$msg = "Transfer complete."; 
		$color = "#99FF66";
	}
}
		
?>
Example #3
0
<?php

include_once "c456182.includes.php";
// TextboxList Autocomplete sample data for queryRemote: false (names are fetched all at once when TextboxList is initialized)
// get names (eg: database)
// the format is:
// id, searchable plain text, html (for the textboxlist item, if empty the plain is used), html (for the autocomplete dropdown)
$response = array();
$places = array();
$placeq = mysql_query("SELECT id, country, street, store, city FROM places", $dbh);
while ($place = mysql_fetch_array($placeq)) {
    $places[] = $place['id'] . ":" . $place['store'] . ":" . $place['street'] . ":" . $place['city'] . ":" . $place['country'];
}
// make sure they're sorted alphabetically, for binary search tests
sort($places);
foreach ($places as $i) {
    $data = explode(":", $i);
    $response[] = array($data[0], changeChars($data[1]) . " @ " . changeChars($data[2]) . ", " . changeChars($data[3]) . ", " . changeChars($data[4]), null, changeChars($data[1]) . " @ " . changeChars($data[2]) . "<div class=\"tags\">" . changeChars($data[3]) . ", " . changeChars($data[4]));
}
function changeChars($string)
{
    return utf8_encode($string);
}
header('Content-type: application/json');
echo json_encode($response);