localhero Posted October 16, 2006 Report Share Posted October 16, 2006 Man ir lapa kur tiek rakstiti teksti. Galvenaja lapaa tiek izvaditi 3 jaunakie ierkasti. ir arii rakstu arhīvs. Tatad man gribetos izveidot rakstru arhīvu kas grupē visus rakstus pa mēnešiem un gadiem. googlee mekleeju bet nezinaju iisti peec kadiem atslegvardiem man mekleet. Varbut ir kadas idejas. Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2006 Report Share Posted October 16, 2006 (edited) Ja tev viss glabājās db (mysql, piem.), un vēlies visu arhīva rakstu virsrakstus izdrukāt hronoloģiski vienā lapā, tad izmanto sql order: ... ORDER BY datums DESC Bet vispār - izskaidro sīkāk kā un ko tieši vēlies, un tad varbūt varēsim tev palīdzēt. Edited October 16, 2006 by andrisp Link to comment Share on other sites More sharing options...
v3rb0 Posted October 16, 2006 Report Share Posted October 16, 2006 grupēt pa mēnešiem/gadiem jau drīzāk ar select * from (select *, .. as menesis from raksti ) as t1 group by t1.menesis select * from (select *, .. as gads from raksti) as t1 group by t1.gads nevis order by Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2006 Report Share Posted October 16, 2006 v3rb0, šie selekti, manuprāt, neatgriezīs visus ierakstus, bet tikai pa vienam no katras grupas. Ja pareizi nopārsēju prātā. Link to comment Share on other sites More sharing options...
Delfins Posted October 16, 2006 Report Share Posted October 16, 2006 Imho grupēšana jātaisa PHP galā... while (row) { if (lastYearMonth != curYearMonth) print sprintf('Arhīvs %s - %s', curYear, curMonth); print row; lastYearMonth = ... } PS: order by gan jāuzliek Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2006 Report Share Posted October 16, 2006 Delfins, tā arī es domāju. Itkā jau varētu no db paņemt visus gadus/datumus, un pēc tam selektot pa gadam/datumam, bet tas manuprāt būtu baigais overkill vai overload vai kā viņu tur sauc :). oft, v3rb0, kā tev sanāk iekrāsot kodu ? :) Link to comment Share on other sites More sharing options...
Delfins Posted October 16, 2006 Report Share Posted October 16, 2006 (edited) andris, [SQL]...[/SQL] select * from mana_tabula WHERE 1 Var arī DB selektēt, tad tas saucās OLAP cube... ja pareiz atminos :)... Atceros RTU oraklī vajadzēja šitādus iekš sql-konsoles vienkāršus `reportus` :) Edited October 16, 2006 by Delfins Link to comment Share on other sites More sharing options...
localhero Posted October 16, 2006 Author Report Share Posted October 16, 2006 Nu es domaju man ir vesela kaudze ar rakstiem un e gribetu lai vinji automatiski arhivetos piemeeram kaa http://laacz.lv/blog/ laacha blogaa. Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2006 Report Share Posted October 16, 2006 Nu ja tu nespēj konkretizēt, ko vēlies, tad nav vērts. Ja vēlies kā laacz blogam, tad ņem wordpress. Link to comment Share on other sites More sharing options...
localhero Posted October 16, 2006 Author Report Share Posted October 16, 2006 Wordpress negrasos njemt gan. biju domajis ka jaatelo ieraksti peec datuma kaa Laacim. Nu ok meginashu konkretizet. 2006 Septembris - 6 raksti. 2006 Oktobris - 1 raksts. 2006 Novembris 231 raksts. 2006 decembris 56 raksti. 2007 janvaris 8 raksti. 2007 februaris 5 raksti. Runa ir par to kaa automatizet to lai automatiski tiek savakti raksti, saskjiroti pa meneshiem un gadiem. Tiek uztaisiti linki ka nospiezhot uz tiem es aizeju uz attieciigaa gada un menesha rakstiem. N utaa kaut kaa. Es saprotu varetu rakstit kveriju: SELECT virsraksts, teksts, datums FROM raksti WHERE datums.menesis = februaris SELECT virsraksts, teksts, datums FROM raksti WHERE datums.menesis = janvaris utt bet ko darit kad pienaks marts. Tipa lai nav jaliek ar roku atkal klat jauns menesis. Es nezinu vai nokjerat domu. Varbut kads ir kaut ko lidzigu taisijis vai kadu manuali lasijis. Busu pateicigs par jebko. BTW paldies visiem kas paliidz. Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2006 Report Share Posted October 16, 2006 Nemācēšu uz fikso pateikt SQL, bet meklē GROUP BY un COUNT keywordus iekš mysql.com dočiem. Link to comment Share on other sites More sharing options...
bubu Posted October 16, 2006 Report Share Posted October 16, 2006 Aptuveni šitā: SELECT datums, COUNT(*) GROUP BY datums (protams, ka tur var kombinēt JOINus klāt) Link to comment Share on other sites More sharing options...
andrisp Posted October 16, 2006 Report Share Posted October 16, 2006 Bija interese pašam uztaisīt, še (Dumpi no db): Tabula piemēram: CREATE TABLE `articles` ( `id` int(11) unsigned NOT NULL auto_increment, `date` date default NULL, `title` varchar(255) collate utf8_latvian_ci NOT NULL, PRIMARY KEY (`id`,`title`), UNIQUE KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_latvian_ci; Pats pieprasījums: SELECT EXTRACT(YEAR FROM `date`) as `year`, EXTRACT(MONTH FROM `date`) as `month`, COUNT(*) as `count` FROM `articles` GROUP BY `year`, `month` ORDER BY `date` DESC Link to comment Share on other sites More sharing options...
localhero Posted October 16, 2006 Author Report Share Posted October 16, 2006 Paldies andrisp. Es jau izmeginaju caur phpmyadmin vis stradaa labi. Kad iztaisishu php scriptu ielikshu te. Link to comment Share on other sites More sharing options...
Recommended Posts