|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: |
$dbuser = 'xxx';
$dbpass = 'xxx';
$dbhost = 'localhost';
$dbname = 'journaldemo';
$dbname2 = '1timebarcode';
$con = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname, $con);
$con2 = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname2, $con2);
$sql = "(SELECT t.transid, t.tdate, t.location, t.pc, SUM(tv.tamount) AS tamount, l.code, l.ttype, 'POINTS' AS tid
FROM transactions t INNER JOIN tvalues tv ON tv.transid2 = t.transid
INNER JOIN lookups l ON l.ttype = tv.ttype
LEFT OUTER JOIN washes w ON w.transid = t.transid
WHERE (t.tdate BETWEEN '2009-03-28' AND '2009-10-27')
AND (t.pc BETWEEN '20000000' AND '79999999')
AND l.code IN ('E', 'G', 'M', 'O', 'F', 'H', 'N', 'Q', 'P')
AND l.ttype NOT IN('4002', '4408')
AND w.transid IS NULL
GROUP BY t.transid)
UNION
(SELECT t.transid, t.tdate, t.location, t.pc, SUM(tv.tamount) AS tamount, l.code, l.ttype, 'WASHES' AS tid
FROM transactions t INNER JOIN tvalues tv ON tv.transid2 = t.transid
INNER JOIN lookups l ON l.ttype = tv.ttype
LEFT OUTER JOIN washes w ON w.transid = t.transid
WHERE (t.tdate BETWEEN '2009-03-28' AND '2009-10-27')
AND (t.pc BETWEEN '20000000' AND '79999999')
AND l.ttype IN ('4060','10110', '10400', '11000', '11001', '11010', '11011', '11013', '18000', '18001', '11016')
AND w.transid IS NULL
GROUP BY t.transid)";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
//need to connect to 2nd db to do update if this is true
if ($row['pc'] >= "30000000" || $row['pc'] <="39999999") {
$sql = "UPDATE barcodes SET active = 0
WHERE human = '".$row['pc']."'";
if (!mysql_query($sql, $con2)) die(mysql_error());
}
elseif ($row['tid'] == "WASHES") {
$sql = "INSERT INTO punch (pc, punchval)
VALUES ('".$row['pc']."', 1)
ON DUPLICATE KEY UPDATE punchval = punchval + 1";
if (!mysql_query($sql, $con)) die(mysql_error());
$sql = "UPDATE punch SET punchval = CASE WHEN punchval > 10 THEN punchval - 11
ELSE punchval + (-11) END
WHERE pc = '".$row['pc']."'
AND EXISTS (SELECT *
FROM tvalues JOIN lookups ON lookups.ttype = tvalues.ttype
WHERE tvalues.transid2 = '".$row['transid']."' AND lookups.ttype IN ('4980','4981'))";
if (!mysql_query($sql, $con)) die(mysql_error());
|
Advertisement
| Hall of Fame |