Witam. Mam pętle while która wyświetla dane z MySQLa. Zrobiłem sortowanie wyników zapytania, lecz ono nie działa. Oto kod
<?php
include('config.php');
$query = query('kategorie', "`ID` = '".$inc[1]."'");
$row = mfa($query);
$query2 = query('podkategorie', "`id_kat` = '".$inc[1]."'");
$row2 = mfa($query2);
show('<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
<link rel="stylesheet" type="text/css" href="'.$URL.'/style.css">
<script type="text/javascript">
function getXMLHttpRequestObject(){
try{
return new XMLHttpRequest();
}
catch(e){
try{
return new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
return false;
}
}
}
function sortuj(co, po){
var XMLHttpRequestObject = getXMLHttpRequestObject();
if(XMLHttpRequestObject){
var span = document.getElementById("products");
var url = "";
if(co == name){
if(po == asc){
url = "'.$URL.'/name-asc.php";
}
if(po == desc){
url = "'.$URL.'/name-desc.php";
}
}
if(co == price){
if(po == asc){
url = "'.$URL.'/price-asc.php";
}
if(po == desc){
url = "'.$URL.'/price-desc.php";
}
}
XMLHttpRequestObject.open("GET", url);
XMLHttpRequestObject.onreadystatechange = function(){
if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
span.innerHTML = XMLHttpRequestObject.responseText;
delete XMLHttpRequestObject;
XMLHttpRequestObject = false
}
}
XMLHttpRequestObject.send(null)
}
}
</script>
</head>');
include('logo.php');
show('
<table class="table_products" align="center">
<tr>
<th class="header" align="left" colspan="4"> <a href="'.$URL.'/" class="aheader">'.INDEX.'</a> >> <a href="'.$URL.'/category/'.$row[0].'/" class="aheader">'.$row[$lang].'</a> >> <a href="'.$URL.'/products/'.$row[0].'/'.$row2[0].'/" class="aheader">'.$row2[$lang].'</a></th>
</tr>
<tr>
<th>
<table class="products">
<tr class="header2">
<th colspan="2" width="625">'.NAME2.'<a href="#" onclick="sortuj(name, desc);"><img src="'.$URL.'/img/sortdesc.gif" border="0" width="10"></a><a href="#" onclick="sortuj(name, asc);"><img src="'.$URL.'/img/sortasc.gif" border="0" width="10"></a></th>
<th width="75">'.PRICE.'</th>
<th width="100">'.SELLER.'</th>
</tr><span id="products"');
$sort = 'ID';
$sort_by = 'ASC';
$query = query('produkty', "`id_kat` = '".$inc[1]."' AND `id_podkat` = '".$inc[2]."' ORDER BY `".$sort."` ".$sort_by."");
$i = 0;
while($row = mfa($query)){
$i++;
$class = $i % 2;
$pro = fopen('procent.sklep', 'r'); $cena = $row[2] / 100 * $pro + $row[2];
$seller = query('users', "`ID` = '".$row[3]."'");
$row2 = mfa($seller);
show('<tr class="cat_'.$class.'">
<th width="50" height="50">zdjecie</th>
<th><a href="'.$URL.'/product/'.$row[0].'/">'.$row[1].'</a></th>
<th>'.$cena.' PLN</th>
<th><a href="'.$URL.'/profile/'.$row2[0].'">'.$row2[1].'</a></th>
</tr>');
}
show('</span></table>
</th>
</tr>
</table>');
?>
Czy ktoś jest w stanie mi powiedzieć czemu to nie działa.
PS strony name-asc.php name-desc.php itp mam utworzone i sa tam atrybuty sortowania odpowiednie