<commit_before><?php
// if the user isn't logged in, send them back to the login page
session_start();
if (!isset($_SESSION['userId']) || !isset($_GET['id'])) {
  header('Location: login.html');
  die();
}

require "load-db.php";
$db = loadDatabase();
      
// get the category
$stmt = $db->prepare('SELECT user_id,name FROM category WHERE id=:id');
$stmt->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
$categories = $stmt->fetchAll(PDO::FETCH_ASSOC);
$category = $categories[0];

// make sure the user owns the requested category
if ($_SESSION['userId'] != $category['user_id']) {
  header('Location: home.php');
  die();
}
// now get all the transactions for that category
$stmt = $db->prepare('SELECT id,`date`,amount,comments FROM transaction WHERE category_id=:id');
$stmt->bindValue(':id', $_GET['id'], PDO::PARAM_INT);<commit_msg>Add an order by clause<commit_after><?php
// if the user isn't logged in, send them back to the login page
session_start();
if (!isset($_SESSION['userId']) || !isset($_GET['id'])) {
  header('Location: login.html');
  die();
}

require "load-db.php";
$db = loadDatabase();
      
// get the category
$stmt = $db->prepare('SELECT user_id,name FROM category WHERE id=:id');
$stmt->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
$stmt->execute();
$categories = $stmt->fetchAll(PDO::FETCH_ASSOC);
$category = $categories[0];

// make sure the user owns the requested category
if ($_SESSION['userId'] != $category['user_id']) {
  header('Location: home.php');
  die();
}
// now get all the transactions for that category
$stmt = $db->prepare('SELECT id,`date`,amount,comments FROM transaction WHERE category_id=:id ORDER BY `date` DESC');
$stmt->bindValue(':id', $_GET['id'], PDO::PARAM_INT);
{'fraction_non_alphanumeric': 0.2006880733944954, 'fraction_numerical': 0.0011467889908256881, 'mean_word_length': 5.78988326848249, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '341467', 'n_tokens_mistral': 561, 'n_tokens_neox': 561, 'n_words': 157}