Using jQuery tablesorter to sort all data from MYSQL
I want to sort all data at the same time in my mysql query results.
how do I do it?
[code]
<?php
require_once('auth.php');
require_once('../config.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title>BTJ Finland Extranet</title>
<link href="style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="themes/blue/style.css" type="text/css" media="print, projection, screen" />
<script type="text/javascript" src="jquery-latest.js"></script>
<script type="text/javascript" src="jquery.tablesorter.js"></script>
<script type="text/javascript" id="js">
$(document).ready(function() {
$("table").tablesorter({widthFixed: true, widgets: ['zebra']})
});
</script>
<link rel="stylesheet" type="text/css" href="shadowbox.css">
<script type="text/javascript" src="shadowbox.js"></script>
<script type="text/javascript">
Shadowbox.init();
</script>
</head>
<body style="background-color: rgb(232, 232, 232);">
<div id="mainPan">
<div style="background-color: rgb(232, 232, 232);">
<div id="leftPan">
<div style="text-align: center;"><img style="width: 114px; height: 44px;" alt="" src="images/loggersson.png" align="top"><br style="font-weight: bold;">
</div>
<br />
<div style="text-align: center;">
<?php
$cust_id = $_SESSION['SESS_USERNAME'];
$connect = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$connect) {
die('Failed to connect to server');
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
die("Unable to select database");
}
$data = mysql_query("SELECT cust_name FROM customer, users WHERE customer.cust_id = users.cust_id AND '$_SESSION[SESS_USERNAME]' = customer.cust_id");
while($info = mysql_fetch_array( $data ))
echo "<b>Olet kirjautunut sisään käyttäjänä {$cust_id} / {$info['cust_name']}</b>";
?>
</div>
<ul style="font-weight: bold;" class="one">
<br>
<li><a href="index.php">Ajankohtaista</a></li>
<li><a href="historia.php">Tilaushistoria</a></li>
<li class="home">Avoimet tilaukset</a></li>
<li><a href="search.php">Tuotehaku<br></a></li>
<li><a href="psswform.php">Salasana<br></a></li>
<li style="text-align: left;"><a href="../logout.php">Kirjaudu ulos</a></li>
</ul>
<br>
</div>
<div style="position: absolute; left: 200px; top: 6px; width: 768px; height: 20px; text-align: center;"><big><big
style="font-weight: bold; color: rgb(0, 0, 0);">Avoimet tilausrivit</big></big><br>
</div>
<div style="position: absolute; left: 200px; top: 55px; width: 768px; height: 32px;">
<?php
session_start();
if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1;
$max_results = 10;
$from = (($page * $max_results) - $max_results);
$cust_id=$_SESSION['SESS_USERNAME'];
$ord_id=$_REQUEST['tilaus'];
$prod_id=$_REQUEST['tuote'];
$data = mysql_query("SELECT product.auth, product.prod_name, product.prod_id, orderline.value, orderline.ordline_batch, orderline.ord_id, orderline.qty, orderline.qty_alloc, orderline.prod_id, orderline.ordline_type, orderline.ordline_stat, DATE_FORMAT(orders.ord_date, '%d.%m.%Y') as date FROM orderline, product, orders WHERE orders.cust_id='$cust_id' AND orderline.prod_id = product.prod_id AND orderline.ord_key=orders.ord_key AND orderline.ordline_type='O' order by orders.ord_date DESC, orderline.ord_id DESC LIMIT $from, $max_results")
or die;
echo "<table width=768 border=0 cellspacing=0 cellpadding=7 class=\"tablesorter\">
<thead>
<tr>
<th width=100px><big><big><b>Tuotenumero</b></big></big></a></th>
<th width=100px><big><big><b>Nimeke</b></big></big></a></th>
<th width=100px><big><big><b>Tekijä</b></big></big></a></th>
<th width=70px><big><big><b>Määrä</b></big></big></a></th>
<th width=70px><big><big><b>Hinta</b></big></big></th>
<th width=100px><big><big><b>Tilaus-päivämäärä</b></big></big></a></th>
<th width=100px><big><big><b>Status</b></big></big></th></tr>
</thead>
<tbody>";
$i=1;
while($info = mysql_fetch_array( $data ))
{
echo "<tr>";
echo "<td width=100px><big><big><a rel=shadowbox;width=625;height=600; href=tuotekortti.php?tuote=".$info['prod_id'] .">".$info['prod_id'] . "</a></big></big></td> ";
echo "<td width=100px><big><big>".$info['prod_name'] . "</big></big></td> ";
echo "<td width=100px><big><big>".$info['auth'] . "</big></big></td> ";
echo "<td width=70px><big><big>".(int)$info['qty'] . "</big></big></td> ";
echo "<td width=70px><big><big>".$info['value'] . "</big></big></td>";
echo "<td width=100px><big><big>".$info['date'] . "</big></big></td> ";
echo "<td width=100px><big><big>".$info['ordline_stat'] . " </big></big></td></tr>";
}
echo "</tbody>";
echo "</table>";
echo "<hr style=width: 100%; height: 2px;>";
$total_results = mysql_result(mysql_query("SELECT COUNT(DISTINCT orderline.ord_id) as Num FROM orders, orderline WHERE orders.ord_id=orderline.ord_id AND orderline.ordline_type='O' AND orders.cust_id='$cust_id'"),0);
$total_pages = ceil($total_results / $max_results);
if($total_results > $max_results)
{
if($page > 1)
{
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?&page=$prev\"><< Edellinen</a> ";
}
for($i = 1; $i <= $total_pages; $i++)
{
if($page == $i)
{
echo $i ." ";
}
else
{
echo "<a href=\"".$_SERVER['PHP_SELF']."?&page=$i\">$i</a> ";
}
}
if($page < $total_pages)
{
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?&page=$next\">>> Seuraava</a> ";
}
}
?>
</div>
</body>
</html>
[/code]