Janhouse Posted October 7, 2005 Report Share Posted October 7, 2005 Taisu to lietu, kas parāda kuri reģistrētie lietotāji ir onlainā. Esmu izdomājis tik tālu, ka datubāzē (mysql) lietotājam saglabā informāciju par to kad viņš ir pēdējo reizi atvēris kādu lapu. Formāts šāds d.m.Y. H:i:s Kā tagad uztaisīt, lai no esošā datuma $datums=date("d.m.Y. H:i:s"); atņem 10 minūtes, lai varu pēc tam uztaisīt tādu lietu: $query = "SELECT vards FROM lietotaji WHERE redzets>=$datums_redz"; ideja, ka tad no laika piemēram 07.10.2005. 17:38:40 atņemtu 10 minūtes. Nemaku no tāda laika formāta atņemt 10 minūtes. :D Lūdzu palīdziet. Zinu, ka nav tik grūti, bet es tik tād iesācējs un ar datumiem nav nācies daudz saskarties. Link to comment Share on other sites More sharing options...
Kavacky Posted October 7, 2005 Report Share Posted October 7, 2005 (edited) string date( string format [, int timestamp]) $datums = date( 'd.m.Y. H:i:s', time() - 600 ); Ā, un šitam labāk uztaisīt jaunu tabulu, kurā ieraksta tos, kas online. Edited October 7, 2005 by Kavacky Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 kapec jaunu tabulu vai ar vienkarsi atsevisku kolonu nepietiek? nu ok darisu ka saki. :) Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 un kur ir kluda ludzu pasaki ? print"Onlainā: "; $datums = date( 'd.m.Y. H:i:s', time() - 600 ); $query = "SELECT vards FROM lietotaji WHERE redzets>=$datums"; $result = mysql_query($query) or die('Neizdevās.'); while(list($_vards)= mysql_fetch_row($result)) { print"$_vards, "; } Link to comment Share on other sites More sharing options...
goldy Posted October 7, 2005 Report Share Posted October 7, 2005 sanaak ka tu tur gribi visu dabuut vienaa rindaa araa no msql - nelogiski vai ne, un kas ir tas $_vards ?? print"Onlainā: "; $datums = date( 'd.m.Y. H:i:s', time() - 600 ); $query = "SELECT vards FROM lietotaji WHERE redzets >= $datums"; $result = mysql_query($query) or die('Neizdevās.'); while ($row = mysql_fetch_array($result)) { echo $row['vards']; } Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 NEEEE!!! es gribu panakt lai tiek paraditi lietotaji, kuri apmeklejusi lapu pedejas 10 minutes. Ludzu nesakiet, ka nav pareizi, jo pats zinu, ka neiet. Vienkarsi paradiet, ka butu pareizi. Link to comment Share on other sites More sharing options...
v3rb0 Posted October 7, 2005 Report Share Posted October 7, 2005 vot taisni shitaadai vajadziibai ljoti labi der timestamps un memory (heap) storage engine. Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 paradi ludzu Link to comment Share on other sites More sharing options...
v3rb0 Posted October 7, 2005 Report Share Posted October 7, 2005 tabula CREATE TABLE online ( user_id INT UNSIGNED NOT NULL , seen INT UNSIGNED NOT NULL ) TYPE = HEAP ; ALTER TABLE online ADD PRIMARY KEY ( user_id ); katru reizi kad useris kaut ko pakliko tad replace into online set user_id=1, seen=unix_timestamp() 1 - vietaa ieliec usera id cik onlinee atrod ar select count(*) as is_online from online where seen > unix_timestamp() - 600 'unix_timestamp()' un 'unix_timestamp() - 600' izreekini php pusee. Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 pec ta unix timestamp man aizdomas, ka tas tik uz unix ies. :D ok pameginasu Link to comment Share on other sites More sharing options...
v3rb0 Posted October 7, 2005 Report Share Posted October 7, 2005 nee, php f-ja time() Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 kaadaa php f? nesapratu tavu domu nu blin.... tu nevari paradit pilnu kodu? nevis dalinu vienu Link to comment Share on other sites More sharing options...
bubu Posted October 7, 2005 Report Share Posted October 7, 2005 nu blin... vari sākt domāt ar visu galvu, nevis ar daļinu no tās? Link to comment Share on other sites More sharing options...
Paulinjsh Posted October 7, 2005 Report Share Posted October 7, 2005 Visiem ar karoti viss jāiebaro, kaut gan man jau arī tā patīk, bet nu cenšos tā vairs nedarīt, jo krīt tak uz nerviem citiem :) Link to comment Share on other sites More sharing options...
Janhouse Posted October 7, 2005 Author Report Share Posted October 7, 2005 tiku galaa. .... taa jocigi es vienmer te ielieku visadus stulbus jautajumus un neko nesaprotu no taa ko jus man te sakat. Tad parokos netaa ieks php.net un visu pats atrodu. :D piedodiet, ka trauceju. :D Link to comment Share on other sites More sharing options...
Recommended Posts