ashais13 Posted May 29, 2010 Report Share Posted May 29, 2010 (edited) SQL: `date` DATE NULL , PHP: $dati=mysql_query("SELECT * FROM viesene ORDER by date DESC LIMIT 10"); GRibētos panākt lai pēdējo ierakstu rāda pašā augšā nevis apakšā.. :/ Mēģināju ORDER by date ASC LIMIT 10, bet nekādu izmaiņu.. Edited May 29, 2010 by ashais13 Quote Link to comment Share on other sites More sharing options...
briedis Posted May 29, 2010 Report Share Posted May 29, 2010 Bet tas date arī satur kādu datumu? Quote Link to comment Share on other sites More sharing options...
ashais13 Posted May 29, 2010 Author Report Share Posted May 29, 2010 (edited) Jā.. Edited May 29, 2010 by ashais13 Quote Link to comment Share on other sites More sharing options...
briedis Posted May 29, 2010 Report Share Posted May 29, 2010 Parādi, kas tieši tiek izvadīts ar esošo kvēriju? Quote Link to comment Share on other sites More sharing options...
ashais13 Posted May 29, 2010 Author Report Share Posted May 29, 2010 nick, body, date, userid Quote Link to comment Share on other sites More sharing options...
mefisto Posted May 29, 2010 Report Share Posted May 29, 2010 Nu bet tas querijs jau izdrukā tev 10 jaunākos ierakstos. Quote Link to comment Share on other sites More sharing options...
ashais13 Posted May 29, 2010 Author Report Share Posted May 29, 2010 Jā bet nepareizā secibā.. - Man vajag lai pats jaunākais rādas pašā augšā nevis pašā apakšā.. Quote Link to comment Share on other sites More sharing options...
briedis Posted May 29, 2010 Report Share Posted May 29, 2010 (edited) Iekopē te tos rezultātus, kas ir napreizā secībā... Edited May 29, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
emsy Posted May 29, 2010 Report Share Posted May 29, 2010 Kādā formātā tev tas date ir??? timestamp vai jau konvertēts, piem. 12.12.2010 12:23:43?? Quote Link to comment Share on other sites More sharing options...
briedis Posted May 29, 2010 Report Share Posted May 29, 2010 (edited) Es sapratu kur ir problēma: the date field is stored as an ISO date in a varchar field and the datetime field is stored in a regular datetime field. Tev jāmaina date kolonnas tips uz datetime, jo date glabājās kā string virkne, pēc tā tad arī kārtojas, kā pēc stringa, nevis loģiskās vērtības. Edited May 29, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
ashais13 Posted May 29, 2010 Author Report Share Posted May 29, 2010 Kādā formātā tev tas date ir??? timestamp vai jau konvertēts, piem. 12.12.2010 12:23:43?? $datums = date('Y-m-d, H:i'); Es sapratu kur ir problēma: Tev jāmaina date kolonnas tips uz datetime, jo date glabājās kā string virkne, pēc tā tad arī kārtojas, kā pēc stringa, nevis loģiskās vērtības. `date` DATETIME NULL , ? Quote Link to comment Share on other sites More sharing options...
briedis Posted May 29, 2010 Report Share Posted May 29, 2010 jā, bet kad tu pievieno ierakstu datubāzei, neformātē datumu ar php, bet gan izmanto NOW() funkciju. INSERT INTO tabula(ieraksts, datums) VALUES('ieraksts', NOW()) NOW() atgriež pašreizējo datumu, laiku... Quote Link to comment Share on other sites More sharing options...
ashais13 Posted May 29, 2010 Author Report Share Posted May 29, 2010 (edited) Lkm nepareizi sastādiju kko, jo tgd visp neko datbuāzē neievada. mysql_query("INSERT INTO shoutbox(nick, body, date, userid) VALUES('$niks','$body','$memb_id' NOW())"); Kr4 ieraksti uzrādās nevis augošā, bet dilstošā secībā.. > root @ 2010-05-30 00:12:00 ghgjhhg root @ 2010-05-30 00:12:00 hgjhgjhg root @ 2010-05-30 00:12:00 ghjhgj root @ 2010-05-30 00:12:00 aaaaa root @ 2010-05-30 00:17:00 pamamp root @ 2010-05-30 00:17:00 lol root @ 2010-05-30 00:18:00 dfd root @ 2010-05-30 00:18:00 asdasd root @ 2010-05-30 00:18:00 dfgdf root @ 2010-05-30 00:28:00 asdasd Edited May 29, 2010 by ashais13 Quote Link to comment Share on other sites More sharing options...
briedis Posted May 29, 2010 Report Share Posted May 29, 2010 Lkm nepareizi sastādiju kko, jo tgd visp neko datbuāzē neievada. mysql_query("INSERT INTO shoutbox(nick, body, date, userid) VALUES('$niks','$body','$memb_id' NOW())"); komata pirms now() ta nav! un bāc, to tev vajadzēja izsecināt no mysql_error()! Quote Link to comment Share on other sites More sharing options...
ashais13 Posted May 29, 2010 Author Report Share Posted May 29, 2010 (edited) Atvaino par visu šito 4akaru, mana kļūda vnk biju piemirsis, pievienot sekundes.. Bija date('Y-m-d, H:i'); ,bet vajadz'eja date('Y-m-d, H:i:s'); Paldies par centību.!! ;) Edited May 29, 2010 by ashais13 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.