witam . mam taki kłopot powiedzmy ze mam listę tematów obok są ikonki ( strzałki w górę i w dół )

przy czym pierwszym rekordzie jest tylko strzałka w dół a ostatnim tylko w górę. jak zrobić coć takiego żeby : jak kliknię na daną strzalke robił update danego rekordu .. ( pola sort )

ja mam taki kod:

ale nic mi do głowy nie przychodzi:


wymyslilem tylko cos takiego zeby pokazywal odp strzalki wedlug w/w schematu

  1. <?php
  2. $varListWykladm = mysql_query (&#092;"SELECT * FROM cours WHERE cours_id = '$cours_id' AND user_id_cours = '$id_user' ORDER by sort DESC LIMIT 1\");
  3. while($strWdm = mysql_fetch_array($varListWykladm))
  4. {
  5.  $msortZs= $strWdm[&#092;"sort\"];
  6. }
  7. $varListWyklad = mysql_query (&#092;"SELECT * FROM cours WHERE cours_id = '$cours_id' AND user_id_cours = '$id_user' ORDER by sort\");
  8.  
  9. if ($upt == '1') {
  10.  
  11. $update_sqls = &#092;"UPDATE cours
  12. SET status = '0'
  13. WHERE id_lesson = '$strIDWyk'&#092;";
  14. $result = $site_db->query($update_sqls);
  15.  
  16. header(&#092;"Location: coursList.php?cours_id=$cours_id&info=sup\");
  17.  
  18. }
  19.  
  20. if ($upt == '0') {
  21.  
  22. $update_sqls = &#092;"UPDATE cours
  23. SET status = '1'
  24. WHERE id_lesson = '$strIDWyk'&#092;";
  25. $result = $site_db->query($update_sqls);
  26.  
  27. header(&#092;"Location: coursList.php?cours_id=$cours_id&info=sap\");
  28. }
  29.  
  30.  
  31.  
  32.  
  33. while($strWd = mysql_fetch_array($varListWyklad))
  34. {
  35.  $strNameWyk= $strWd[&#092;"title\"];
  36.  $strIDWyk= $strWd[&#092;"id_lesson\"];
  37.  $soty= $strWd[&#092;"sort\"];
  38.  $widok = $strWd[&#092;"status\"];
  39.  
  40. if ($widok == '1') {
  41.  
  42. $st_cours = &#092;"<a href=coursList.php?cours_id=$cours_id&upt=1&strIDWyk=$strIDWyk><img src=gmx/open.gif border=0></a>\";
  43. }else{
  44. $st_cours = &#092;"<a href=coursList.php?cours_id=$cours_id&upt=0&strIDWyk=$strIDWyk><img src=gmx/close.gif border=0></a>\";
  45.  
  46. }
  47.  
  48. if ($soty == &#092;"1\") { 
  49.  
  50. $pokaz = &#092;"<img src=\"admin/images/arrow_down.gif\" border=\"0\" > \";
  51.  
  52. } 
  53.  
  54. if ($soty == &#092;"$msortZs\") { 
  55.  
  56. $pokaz = &#092;"$sn_d <img src=\"admin/images/arrow_up.gif\" border=\"0\">\";
  57.  
  58. } 
  59.  
  60. if (($soty > &#092;"1\" ) && ($soty < \"1000\" ))
  61.  
  62. { 
  63.  
  64. $pokaz_ico_two = &#092;"<img src=\"admin/images/arrow_up.gif\" border=\"0\">\";
  65.  
  66. } 
  67.  
  68. if ($soty == &#092;"$msortZs\") { 
  69.  
  70. $pokaz_ico_two = &#092;"\";
  71.  
  72. } 
  73.  
  74.  
  75. if (@$zmC){
  76.  
  77.  
  78.  $Upsoty = $soty +1;
  79.  $pokazSpis .= &#092;"<table height=\"29\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" bgColor=\"#F3F3F3\" id=\"table4\">
  80. <tr>
  81. <td vAlign=&#092;"center\" width=\"52%\" height=\"29\"><b>&nbsp;$soty $strNameWyk</b></td>
  82. <td vAlign=&#092;"center\" width=\"16%\" height=\"29\">&nbsp;&nbsp;
  83. <a href=#$Up$soty>$pokaz</a> $pokaz_ico_two $sn_d
  84. </td>
  85. <td vAlign=&#092;"center\" width=\"10%\" height=\"29\">&nbsp; &nbsp;&nbsp;<a href=coursUpdate.php?akcion=update&cours_update=$strIDWyk&cours_id=$cours_id><img src=gmx/edit_ico.gif border=0></a></td>
  86. <td vAlign=&#092;"center\" width=\"8%\" height=\"29\">&nbsp;&nbsp;$st_cours</td>
  87. <td vAlign=&#092;"center\" width=\"8%\" height=\"29\">&nbsp;&nbsp;&nbsp;<a href=coursList.php?akcja=del&cours_id_del=$strIDWyk&cours_id=$cours_id><img src=\"gmx/del.png\" border=\"0\" onClick=\"return confirm('$dudel_')\";></a></td>
  88. </tr>
  89. </table>&#092;";
  90.  
  91. $zmC = false;
  92. }else{
  93.  
  94.  $pokazSpis .= &#092;"<table height=\"29\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" bgColor=\"#FFF7F2\" id=\"table4\">
  95. <tr>
  96. <td vAlign=&#092;"center\" width=\"52%\" height=\"29\"><b>&nbsp;$soty $strNameWyk</b></td>
  97. <td vAlign=&#092;"center\" width=\"16%\" height=\"29\">&nbsp;&nbsp;
  98. <a href=#$Up$soty>$pokaz</a> $pokaz_ico_two $sn_d
  99. </td>
  100. <td vAlign=&#092;"center\" width=\"10%\" height=\"29\">&nbsp; &nbsp;&nbsp;<a href=coursUpdate.php?akcion=update&cours_update=$strIDWyk&cours_id=$cours_id><img src=gmx/edit_ico.gif border=0></a></td>
  101. <td vAlign=&#092;"center\" width=\"8%\" height=\"29\">&nbsp;&nbsp;$st_cours</td>
  102. <td vAlign=&#092;"center\" width=\"8%\" height=\"29\">&nbsp;&nbsp;&nbsp;<a href=coursList.php?akcja=del&cours_id_del=$strIDWyk&cours_id=$cours_id><img src=\"gmx/del.png\" border=\"0\" onClick=\"return confirm('$dudel_')\";></a></td>
  103. </tr>
  104. </table>&#092;";
  105. $zmC = true;
  106. }
  107. }
  108.  
  109. if ($akcja == 'del')
  110.  
  111. {
  112.  
  113. // usuwanie rekordu
  114.  
  115. $sql_del = &#092;"DELETE FROM cours WHERE id_lesson = '$cours_id_del'\";
  116.  
  117.  
  118.  
  119. $pok_sort = mysql_query (&#092;"SELECT * FROM cours WHERE id_lesson = '$cours_id_del'\");
  120. while($varft = mysql_fetch_array($pok_sort))
  121. {
  122.  $sortID= $varft[&#092;"sort\"];
  123. }
  124.  
  125.  
  126. $maxIdcours = mysql_query (&#092;"SELECT * FROM cours WHERE cours_id = '$cours_id'\");
  127. $maxs = mysql_num_rows($maxIdcours);
  128. $max = $maxs - 1;
  129.  
  130.  
  131.  
  132. for ($i = $sortID; $i <= $max; $i++) // id które usuwasz i najwieksze id w tablei
  133. {
  134.  
  135. $z = $i+1;
  136. $na= $i;
  137.  
  138. $update_sqls = &#092;"UPDATE cours
  139. SET sort = '$na'
  140. WHERE sort = '$z'&#092;";
  141. $result = $site_db->query($update_sqls);
  142.  
  143. }
  144. ?>