Commit: 01525ef163b4249367a50795bc25395639a41f4c Author: Sherif Ramadan <[email protected]> Tue, 25 Dec 2012 00:08:38 -0500 Parents: e0f6118a27b85395a575bb836fcce551b2575d15 Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=01525ef163b4249367a50795bc25395639a41f4c Log: To avoid confusion use a different column name for rating and fall back to manual calculation if it's not present. Changed paths: M manage/user-notes.php Diff: diff --git a/manage/user-notes.php b/manage/user-notes.php index 5a24d1b..02462d7 100644 --- a/manage/user-notes.php +++ b/manage/user-notes.php @@ -127,7 +127,7 @@ if (!$action) { } else if ($type == 3) { $sql = "SELECT SUM(votes.vote) AS up, (COUNT(votes.vote) - SUM(votes.vote)) AS down, ". "ROUND((SUM(votes.vote) / COUNT(votes.vote)) * 100) AS rate, ". - "(SUM(votes.vote) - (COUNT(votes.vote) - SUM(votes.vote))) AS rating, ". + "(SUM(votes.vote) - (COUNT(votes.vote) - SUM(votes.vote))) AS arating, ". "note.id, note.sect, note.user, note.note, UNIX_TIMESTAMP(note.ts) AS ts ". "FROM note ". "JOIN(votes) ON (note.id = votes.note_id) ". @@ -136,7 +136,7 @@ if (!$action) { } else if ($type == 4) { $sql = "SELECT SUM(votes.vote) AS up, (COUNT(votes.vote) - SUM(votes.vote)) AS down, ". "ROUND((SUM(votes.vote) / COUNT(votes.vote)) * 100) AS rate, ". - "(SUM(votes.vote) - (COUNT(votes.vote) - SUM(votes.vote))) AS rating, ". + "(SUM(votes.vote) - (COUNT(votes.vote) - SUM(votes.vote))) AS arating, ". "note.id, note.sect, note.user, note.note, UNIX_TIMESTAMP(note.ts) AS ts ". "FROM note ". "JOIN(votes) ON (note.id = votes.note_id) ". @@ -268,7 +268,7 @@ if (!$action) { $id = isset($row['id']) ? $row['id'] : null; /* This div is only available in cases where the query includes the voting info */ if (isset($row['up']) && isset($row['down'])) { - $rating = $row['rating']; + $rating = isset($row['arating']) ? $row['arating'] : ($row['up'] - $row['down']); if ($rating < 0) { $rating = "<span style=\"color: red;\">$rating</span>"; } elseif ($rating > 0) { -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
