andre Posted October 20, 2003 Report Share Posted October 20, 2003 ja mums ir tabula ar vienu kollonu names select * from names tad seciiba ir shaada ir no pasha vecaakaa (ierakstiita) uz pashu jaunaako (peedeejo ierakstu), bet vajag ptraadi, lai saakumaa raada pashus jaunaakos ierakstus kaa var selektot otraadi, ja ir desc, tad vajag asc, un ja nav datums ierastiits Link to comment Share on other sites More sharing options...
Kaklz Posted October 20, 2003 Report Share Posted October 20, 2003 ja mums ir tabula ar vienu kollonu namesselect * from names tad seciiba ir shaada ir no pasha vecaakaa (ierakstiita) uz pashu jaunaako (peedeejo ierakstu), bet vajag ptraadi, lai saakumaa raada pashus jaunaakos ierakstus kaa var selektot otraadi, ja ir desc, tad vajag asc, un ja nav datums ierastiits atliek tikai uzmineet datubaazes struktuuru un jautaajums kljuust triviaals ;) Link to comment Share on other sites More sharing options...
jurisv Posted October 21, 2003 Report Share Posted October 21, 2003 ja ir kads id ar autoincrement, tad var to id asc desc sorteet..... ja nav pilnigi nekada lauka kas noraditu kaut kadu sortejamu secibu, tad diemzel grauz nagus par to ka tev nav pareizi uztaisita tabula... Link to comment Share on other sites More sharing options...
andre Posted October 21, 2003 Author Report Share Posted October 21, 2003 bet kaappeec peec defaulta tas tiek sakaartots tieshi taadaa seciibaaa ? kaapeec nevar otraadaak ? Link to comment Share on other sites More sharing options...
Roze Posted October 21, 2003 Report Share Posted October 21, 2003 Tapeec ka shajaa variantaa MySQLs nepeeckaa nekaarto bet gan vienkaarshi njem katru ierakstu peec kaartas (nav noraadiiti nekaadi ORDER BY (ja ir kaads lauks tad var like ASC kas ir augoshaa vai DESC dilstoshaa secibaa). Tachu ja kaa jau mineets nav nekaadi incementaali lauki (autoid) vai pievienoshanas datumi tad vienigaa iespeeja ir ielasiit visu masiivaa un tam taisiit array_reverse() un tad izvadiit katru masiiva elementu.. IIsumaa kods aptuvens.. <code><font color="#000000"> <font color="#0000CC"><? $mas </font><font color="#006600">= array(); </font><font color="#0000CC">$result </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/mysql_query]mysql_query[/url]</font><font color="#006600">(</font><font color="#CC0000">"select lauks from names"</font><font color="#006600">); while(</font><font color="#0000CC">$row </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/mysql_fetch_assoc]mysql_fetch_assoc[/url]</font><font color="#006600">(</font><font color="#0000CC">$result</font><font color="#006600">)) { </font><font color="#0000CC">$mas</font><font color="#006600">[</font><font color="#0000CC">[url=http://lv.php.net/count]count[/url]</font><font color="#006600">(</font><font color="#0000CC">$mas</font><font color="#006600">)] = </font><font color="#0000CC">$row</font><font color="#006600">[</font><font color="#0000CC">lauks</font><font color="#006600">]; } </font><font color="#0000CC">$act </font><font color="#006600">= </font><font color="#0000CC">[url=http://lv.php.net/array_reverse]array_reverse[/url]</font><font color="#006600">(</font><font color="#0000CC">$act</font><font color="#006600">); foreach(</font><font color="#0000CC">$act </font><font color="#006600">as </font><font color="#0000CC">$key </font><font color="#006600">=> </font><font color="#0000CC">$value</font><font color="#006600">) { echo </font><font color="#0000CC">$value</font><font color="#006600">.</font><font color="#CC0000">" "</font><font color="#006600">; } </font><font color="#0000CC">?> </font> </font> </code> Link to comment Share on other sites More sharing options...
Qued Posted October 22, 2003 Report Share Posted October 22, 2003 Roze, man patīk tava izpalīdzība. Tomēr visam šim procesam ir savi negatīvie aspekti: sanāk, ka ļautiņiem tiek mācīts, kā apiet vāji plānotas datubāzes nepilnības. Tādēļ vismaz es ieteiktu andre kā primāro un ieteicamāko variantu izvēlēties tabulas papildināšanu ar autoincrement lauku. Link to comment Share on other sites More sharing options...
Recommended Posts