ezs Posted October 6, 2004 Author Report Share Posted October 6, 2004 nu itkā +- viss tagad ir ok es izmantoju šādu kodu <?php if($act == "up"){ $ress = mysql_query("SELECT poz FROM nav WHERE id ='$ida'") or die (mysql_error()); list($ord) = mysql_fetch_row($ress); mysql_free_result($ress); $res = mysql_query("SELECT id, poz FROM nav WHERE poz < $ord ORDER BY poz LIMIT 1") or die (mysql_error()); if (mysql_num_rows($res) <> 0) { list($id2, $ord2) = mysql_fetch_row($res); $t = $ord + $ord2; mysql_unbuffered_query("UPDATE nav SET poz = $t - poz WHERE id IN ('$ida', '$id2')") or die (mysql_error()); } mysql_free_result($res) or die (mysql_error()); echo "tasam UP"; $refer = $_SERVER['HTTP_REFERER']; echo "<meta http-equiv=\"refresh\" content=\"1;URL=".$refer."\">"; } if($act == "down"){ $ress = mysql_query("SELECT poz FROM nav WHERE id ='$ida'") or die (mysql_error()); list($ord) = mysql_fetch_row($ress); mysql_free_result($ress); $res = mysql_query("SELECT id, poz FROM nav WHERE poz > $ord ORDER BY poz LIMIT 1") or die (mysql_error()); if (mysql_num_rows($res) <> 0) { list($id2, $ord2) = mysql_fetch_row($res); $t = $ord + $ord2; mysql_unbuffered_query("UPDATE nav SET poz = $t - poz WHERE id IN ('$ida', '$id2')") or die (mysql_error()); } mysql_free_result($res) or die (mysql_error()); echo "tasam Down"; $refer = $_SERVER['HTTP_REFERER']; echo "<meta http-equiv=\"refresh\" content=\"1;URL=".$refer."\">"; } ?> problēmas rodas ar UP ja down tad viss ir korekti liek pa vienu uz leju bet ja up tad uzmet pašā augšā WHERE poz > $ord nomainu uz WHERE poz < $ord, bet es nesaproti kādēļ tiek padoots pac pirmains id ? tapa dati tiek uzmesti līdz pašai augšai man vienkārši nav ideju itkā vajadzētu veik pretēju darbību WHERE poz > $ord tas ir WHERE poz < $ord bet tad met pašā augšā :( Link to comment Share on other sites More sharing options...
bubu Posted October 6, 2004 Report Share Posted October 6, 2004 (edited) Eh, tu pat norakstīt to ko tev iedod nemāki! Salīdzini manis abus dotos kverijus up/down bīdīšanai otrajā postā, tieši ORDER BY daļu! Edited October 6, 2004 by bubu Link to comment Share on other sites More sharing options...
neo Posted March 31, 2006 Report Share Posted March 31, 2006 Shitais ir labs piemeers. Viss straadaa ok, bet ir viens jautaajums: gadiijumaa ja man seciiba kaut kaadiem ierakstiem piemeeram ir 1,2,3,6,8,10 , kaa var uztaisiit lai visi seciibas numuri sakaartotos peec kaartas? Link to comment Share on other sites More sharing options...
bubu Posted March 31, 2006 Report Share Posted March 31, 2006 Ko nozīmē pēc kārtas? Augošā secībā? Ja jā, tad RTFM. Link to comment Share on other sites More sharing options...
neo Posted March 31, 2006 Report Share Posted March 31, 2006 (edited) It kaa es te uztaisiiu vinu veidu. Straadaat straadaa, bet cik tas ir efektiivi - hvz! http://paste.php.lv/3555 Edited March 31, 2006 by neo Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 31, 2006 Report Share Posted March 31, 2006 (edited) neo --> ko tu ar to gribeeji panaakt? parkaartot datus pashaa DB tabulaa? Tas tachu bezjeedziigi.... palasi par DB un kaa tur tiek glabaati dati... lai atlasiitie dati buutu sakartoti peec tev vajadziigaa lauka (tavaa gdijuma `seciba`) tad vienkaarshi augoshaa seciibaa ORDER BY seciba ASC dilstoshaa ceciibaa ORDER BY seciba DESC ------- SQL pati leiliski sakarto datus :) + ir iespeeja tos arii sagrupeet vispaar RTFM Edited March 31, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
neo Posted March 31, 2006 Report Share Posted March 31, 2006 (edited) Tieshi taa, paarrakstiit datus pashaa tabulaa, taatad ja ir lauks "seciiba" kuraa ir ieraksti piem. 1,2,4,7,9,10 , kopaa 6 ieraksti. Taadat es vinus paarrakstu kaa 1,2,3,4,5,6. Tas domaats taa ja saakumaa ir kaut kaadi ieraksti kuriem seciiba ir 1,2,3,4,5,6, tad kaadu no tiem izdzeeshot, piem 3, paliek attieciigi 1,2,4,5,6. Taatad es vinus sakaartoju attieciigi 1,2,3,4,5. It kaa taada taa jeega ir. Var jau arii taa nepaarrakstiit, protams var grupeet ORDER BY, bet tad ja man kaut kur jaatraada seciibas lauka ieraksti, un tajos ir kaut kas padzeests, tad stulbi izskataas, ka viss nav peec kaartas. Edited March 31, 2006 by neo Link to comment Share on other sites More sharing options...
Recommended Posts