Skrypt ma za zadanie sortować dane pobrane z bazy danych według poszczególnych kolumn jednak tak się nie dzieje :/.
Kod:
<?php require_once('HTML/Table.php'); try { $dbh = new PDO('mysql:host=localhost;dbname=shop', 'root', 'root'); } catch(PDOException $exception) { } @ $table->setHeaderContents(0, 0, "<a href=\"{$_SERVER['PHP_SELF']}?sort=id\">ID Zamowienia</a>"); @ $table->setHeaderContents(0, 1, "<a href=\"{$_SERVER['PHP_SELF']}?sort=client_id\">ID Klienta</a>"); @ $table->setHeaderContents(0, 2, "<a href=\"{$_SERVER['PHP_SELF']}?sort=order_time\">Data zamowienia</a>"); @ $table->setHeaderContents(0, 3, "<a href=\"{$_SERVER['PHP_SELF']}?sort=sub_total\">Wartosc towarow</a>"); @ $table->setHeaderContents(0, 4, "<a href=\"{$_SERVER['PHP_SELF']}?sort=shipping_cost\">Koszty przesylki</a>"); @ $table->setHeaderContents(0, 5, "<a href=\"{$_SERVER['PHP_SELF']}?sort=total_cost\">Wartosc sumaryczna</a>"); $query = "SELECT id, client_id, order_time, sub_total, shipping_cost, total_cost FROM sales ORDER BY :sort_method"; $stmt = $dbh->prepare($query); $stmt->bindParam(':sort_method', $sort_method); $stmt->execute(); $rownum = 1; while($row = $stmt->fetch()) { @ $table->setCellContents($rownum, 0, $row['id']); @ $table->setCellContents($rownum, 1, $row['client_id']); @ $table->setCellContents($rownum, 2, $row['order_time']); @ $table->setCellContents($rownum, 3, $row['sub_total']); @ $table->setCellContents($rownum, 4, $row['shipping_cost']); @ $table->setCellContents($rownum, 5, $row['total_cost']); $rownum++; } ?>
Proszę o pomoc