wiki:ImportantCase2

Version 7 (modified by 222039, 5 days ago) ( diff )

--

Приказ на сите книги

Актери

  • Најавен корисник

Чекор 1

Избор на жанра/и

SELECT book.bookid, book.CoverImage, book.Title, book.Genre, book.PublishedYear, author.FirstName, author.LastName
                            FROM Book
                            INNER JOIN Book_Author ON Book.BookID = Book_Author.BookID
                            INNER JOIN Author ON Book_Author.AuthorID = Author.AuthorID
                            WHERE book.genre IN ($placeholders) AND book.PublishedYear BETWEEN $query_from AND $query_to;"
SELECT book.bookid, book.CoverImage, book.Title, book.Genre, book.PublishedYear, author.FirstName, author.LastName
                            FROM Book
                            INNER JOIN Book_Author ON Book.BookID = Book_Author.BookID
                            INNER JOIN Author ON Book_Author.AuthorID = Author.AuthorID WHERE book.PublishedYear BETWEEN $query_from AND $query_to;

Чекор 2

Избор на временски период

SELECT MIN(PublishedYear) as min_year, MAX(PublishedYear) as max_year FROM Book

Чекор 3

Сортирање на книгите по избор, и селектирање на "Apply Filters"

  function sortBooks(books, sortType) {
    const sortedBooks = [...books]; 
    
    switch(sortType) {
        case 'name-asc':
            sortedBooks.sort((a, b) => a.title.localeCompare(b.title));
            break;
        case 'name-desc':
            sortedBooks.sort((a, b) => b.title.localeCompare(a.title));
            break;
        case 'year-desc':
            sortedBooks.sort((a, b) => b.publishedYear - a.publishedYear);
            break;
        case 'year-asc':
            sortedBooks.sort((a, b) => a.publishedYear - b.publishedYear);
            break;
        case 'relevance':
        default:
            break;
    }
    
    return sortedBooks;
}

Чекор 4

Резултат

Attachments (4)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.