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
  1. <?php
  2. include('config.php');
  3. $query = query('kategorie', "`ID` = '".$inc[1]."'");
  4. $row = mfa($query);
  5. $query2 = query('podkategorie', "`id_kat` = '".$inc[1]."'");
  6. $row2 = mfa($query2);
  7. print_r($inc);
  8. show('<html>
  9. <head>
  10. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  11.  
  12. <link rel="stylesheet" type="text/css" href="'.$URL.'/style.css">
  13. <script type="text/javascript">
  14. function getXMLHttpRequestObject(){
  15. try{
  16. return new XMLHttpRequest();
  17. }
  18. catch(e){
  19. try{
  20. return new ActiveXObject("Microsoft.XMLHTTP");
  21. }
  22. catch(e){
  23. return false;
  24. }
  25. }
  26. }
  27. function sortuj(co, po){
  28. var XMLHttpRequestObject = getXMLHttpRequestObject();
  29. if(XMLHttpRequestObject){
  30. var span = document.getElementById("products");
  31. var url = "";
  32. if(co == name){
  33. if(po == asc){
  34. url = "'.$URL.'/name-asc.php";
  35. }
  36. if(po == desc){
  37. url = "'.$URL.'/name-desc.php";
  38. }
  39. }
  40. if(co == price){
  41. if(po == asc){
  42. url = "'.$URL.'/price-asc.php";
  43. }
  44. if(po == desc){
  45. url = "'.$URL.'/price-desc.php";
  46. }
  47. }
  48. XMLHttpRequestObject.open("GET", url);
  49. XMLHttpRequestObject.onreadystatechange = function(){
  50. if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
  51. span.innerHTML = XMLHttpRequestObject.responseText;
  52. delete XMLHttpRequestObject;
  53. XMLHttpRequestObject = false
  54. }
  55. }
  56. XMLHttpRequestObject.send(null)
  57. }
  58. }
  59.  
  60. </script>
  61. </head>');
  62. include('logo.php');
  63. show('
  64. <table class="table_products" align="center">
  65. <tr>
  66. <th class="header" align="left" colspan="4">&nbsp;&nbsp;<a href="'.$URL.'/" class="aheader">'.INDEX.'</a>&nbsp;&nbsp;>>&nbsp;&nbsp;<a href="'.$URL.'/category/'.$row[0].'/" class="aheader">'.$row[$lang].'</a>&nbsp;&nbsp;>>&nbsp;&nbsp;<a href="'.$URL.'/products/'.$row[0].'/'.$row2[0].'/" class="aheader">'.$row2[$lang].'</a></th>
  67. </tr>
  68. <tr>
  69. <th>
  70. <table class="products">
  71. <tr class="header2">
  72. <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>
  73. <th width="75">'.PRICE.'</th>
  74. <th width="100">'.SELLER.'</th>
  75. </tr><span id="products"');
  76. $sort = 'ID';
  77. $sort_by = 'ASC';
  78. $query = query('produkty', "`id_kat` = '".$inc[1]."' AND `id_podkat` = '".$inc[2]."' ORDER BY `".$sort."` ".$sort_by."");
  79. $i = 0;
  80. while($row = mfa($query)){
  81. $i++;
  82. $class = $i % 2;
  83. $pro = fopen('procent.sklep', 'r');
  84. $pro = fgets($pro);
  85. $cena = $row[2] / 100 * $pro + $row[2];
  86. $seller = query('users', "`ID` = '".$row[3]."'");
  87. $row2 = mfa($seller);
  88. show('<tr class="cat_'.$class.'">
  89. <th width="50" height="50">zdjecie</th>
  90. <th><a href="'.$URL.'/product/'.$row[0].'/">'.$row[1].'</a></th>
  91. <th>'.$cena.' PLN</th>
  92. <th><a href="'.$URL.'/profile/'.$row2[0].'">'.$row2[1].'</a></th>
  93. </tr>');
  94. }
  95. show('</span></table>
  96. </th>
  97. </tr>
  98.  
  99. </table>');
  100.  
  101. ?>

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