2. Nie wyświetlają się tabele z dir=DESC.
3. Przy wpisywaniu w przeglądarce zmiennych get wszystko ładnie działa
4. Skopiowałem to z innej strony, ale nie było na niej searchname
<? connect(); $_SESSION['logged'] = filter_var($_SESSION['logged'], FILTER_SANITIZE_STRING); { $_GET['sortby'] = filter_var($_GET['sortby'], FILTER_SANITIZE_STRING); $_SESSION['sortby'] = $_GET['sortby']; } $sortby = $_SESSION['sortby']; { $_GET['dir'] = filter_var($_GET['dir'], FILTER_SANITIZE_STRING); $_SESSION['dir'] = $_GET['dir']; } $dir = $_SESSION['dir']; { $_GET['page'] = filter_var($_GET['page'], FILTER_SANITIZE_STRING); $_SESSION['page'] = $_GET['page']; } $page = $_SESSION['page']; { $_POST['searchname'] = filter_var($_POST['searchname'], FILTER_SANITIZE_STRING); $_SESSION['searchname'] = $_POST['searchname']; } $searchname = $_SESSION['searchname']; { { $_SESSION['searchname'] = $_POST["searchname"]; $searchname = $_SESSION['searchname']; $query = " SELECT * from table_books WHERE author LIKE '%$searchname%' OR book_name LIKE '%$searchname%' "; } { } else { { { $_GET['page'] = filter_var($_GET['page'], FILTER_SANITIZE_STRING); if (($_GET['page'] > $num_of_pages) ) { exit; } if ($_GET['page']!=NULL) { exit; } } } function sort_first_table() { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } {
...
Dalsza część kodu
if ($_SESSION['sortby'] == "book_id") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=DESC'>ID ∧</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } if ($_SESSION['sortby'] == "book_name") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=DESC'>Book Name ∧</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } if ($_SESSION['sortby'] == "author") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=DESC'>Author ∧</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } if ($_SESSION['sortby'] == "publishing_house") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=DESC'>Publishing house ∧</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } if ($_SESSION['sortby'] == "year_of_publication") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=DESC'>Year of publication ∧</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } if ($_SESSION['sortby'] == "binding") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASSC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=DESC'>Binding ∧</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } if ($_SESSION['sortby'] == "availability") { if ($_SESSION['dir'] == "ASC") { echo "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASSC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=DESC'>Availability ∧</a></th> </tr>"; } else if ($_SESSION['dir'] == "DESC") { sort_first_table(); } } } } } else { "<table bgcolor=#EEEEEE border=1 align=center width='920'><tr> <th>LP</th> <th><a href='searchbooks.php?sortby=book_id&dir=ASC'>ID ∨</a></th> <th><a href='searchbooks.php?sortby=book_name&dir=ASC'>Book Name ∨</a></th> <th><a href='searchbooks.php?sortby=author&dir=ASC'>Author ∨</a></th> <th><a href='searchbooks.php?sortby=publishing_house&dir=ASC'>Publishing house ∨</a></th> <th><a href='searchbooks.php?sortby=year_of_publication&dir=ASC'>Year of publication ∨</a></th> <th><a href='searchbooks.php?sortby=binding&dir=ASC'>Binding ∨</a></th> <th><a href='searchbooks.php?sortby=availability&dir=ASC'>Availability ∨</a></th></tr>"; } ?>
Jeszcze taki searchbar na początku