Quote database webapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unrated.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?PHP
  2. require_once('inc/database.php');
  3. require_once('inc/account.php');
  4. require_once('inc/settings.php');
  5. if (!isset($_SESSION['uid'])) { header('Location: '.BASE.'latest'); exit; }
  6. define('TITLE', 'Unrated');
  7. require_once('inc/header.php');
  8. $sql = 'SELECT quote_id FROM ratings WHERE user_id = '.$_SESSION['uid'];
  9. $res = mysql_query($sql);
  10. $s = '(1';
  11. while ($row = mysql_fetch_array($res)) {
  12. $s .= ' AND quote_id <> '.$row[0];
  13. }
  14. $s .= ')';
  15. $sql = 'SELECT quote_id, quote_quote, quote_rating FROM quotes WHERE '.$s.' ORDER BY quote_id DESC LIMIT 0,25';
  16. $res = mysql_query($sql)
  17. ?>
  18. <div>
  19. <h2>Unrated quotes</h2>
  20. <?PHP
  21. if (mysql_num_rows($res) == 0) {
  22. echo '<p>You\'ve rated every quote in the database! Why not <a href="'.BASE.'"submit">add a new one?</a></p>';
  23. }
  24. $i = 0;
  25. while ($row = mysql_fetch_array($res)) {
  26. $i = 1 - $i;
  27. if ($i == 1) { $e = 'even'; } else { $e = 'odd'; }
  28. ?>
  29. <div class="quote <?PHP echo $e; ?>">
  30. <?PHP
  31. if (isset($_SESSION['uid'])) {
  32. doRate($row['quote_id']);
  33. }
  34. ?>
  35. <p>
  36. Quote <a href="<?PHP echo BASE; ?>browse?q=<?PHP echo $row['quote_id']; ?>">#<?PHP echo $row['quote_id']; ?></a>.
  37. Rating <?PHP echo round($row['quote_rating'],2); ?>.
  38. <?PHP
  39. if (!isset($_SESSION['uid'])) {
  40. echo ' <a href="'.BASE.'login">Login to rate</a>.';
  41. }
  42. ?>
  43. </p>
  44. <div class="quotebody">
  45. <?PHP echo nl2br(htmlentities($row['quote_quote'], ENT_QUOTES, 'UTF-8')); ?>
  46. </div>
  47. </div>
  48. <?PHP
  49. }
  50. ?>
  51. </div>
  52. <?PHP
  53. require_once('inc/footer.php');
  54. ?>