Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Javascript on exit...pomoc

 
Post new topic   Reply to topic    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
F34R



Joined: 08 Mar 2009
Posts: 30
Location: Metković

PostPosted: 17.12.2009 21:07    Post subject: Javascript on exit...pomoc Add user to your forum ignore list Reply with quote

Nisam neki expert u js-u pa vas molim za pomoc... Embarassed

Dakle, recimo da u mysql bazi imam tablicu koja se zove "onlineusers". Svaki put kad se neko logira njegov username se sprema u tu bazu pod red "username".

E sad, imam problema sa brisanjem iz te baze...Naime, kad netko ode na logout.php, izbrise ga iz onlineusers tablice i to radi, ali normalno je da ljudi ne idu na logout.php vec samo napuste stranicu kad su gotovi. U tom slucaju, njihov nickname ostane u toj bazi!

Treba mi skripta (js), koja ce izbrisati $username iz tablice kad netko napusti stranicu...
Back to top
View user's profile Send private message MSN Messenger
hrvoje_86



Joined: 06 Dec 2006
Posts: 107
Location: Zagreb

PostPosted: 17.12.2009 22:37    Post subject: Add user to your forum ignore list Reply with quote

http://www.devarticles.com/c/a/PHP/The-Quickest-Way-To-Count-Users-Online-With-PHP/
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
F34R



Joined: 08 Mar 2009
Posts: 30
Location: Metković

PostPosted: 17.12.2009 23:00    Post subject: Add user to your forum ignore list Reply with quote

hrvoje_86 wrote:
http://www.devarticles.com/c/a/PHP/The-Quickest-Way-To-Count-Users-Online-With-PHP/

Quote:
Treba mi skripta (js), koja ce izbrisati $username iz tablice kad netko napusti stranicu...

=\
To sto mi dao ne radi na bazu...Meni treba bas na bazu...I ne treba mi da izlista online usere, to imam...treba mi js kod da izbrisem neki username iz tablice. Dakle,

<BODY onUnload="....
Back to top
View user's profile Send private message MSN Messenger
hrvoje_86



Joined: 06 Dec 2006
Posts: 107
Location: Zagreb

PostPosted: 17.12.2009 23:54    Post subject: Add user to your forum ignore list Reply with quote

Pa sam si sad napiso
Code:

onUnload="goodbye()"

// ako korsitiš jquery
function goodbye()
{
$.get("logout.php", { name: "korisnik123123" } );

}

Koje je tvoje pitanje u biti kako pozvati php ?
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
F34R



Joined: 08 Mar 2009
Posts: 30
Location: Metković

PostPosted: 18.12.2009 00:57    Post subject: Add user to your forum ignore list Reply with quote

hrvoje_86 wrote:
Pa sam si sad napiso
Code:

onUnload="goodbye()"

// ako korsitiš jquery
function goodbye()
{
$.get("logout.php", { name: "korisnik123123" } );

}

Koje je tvoje pitanje u biti kako pozvati php ?

Pa da...evo probat cu to pa javim dal radi...Hvala
edit:

Ne radi...ne izvrsi logout.php...
Back to top
View user's profile Send private message MSN Messenger
fun.ky



Joined: 05 Jan 2006
Posts: 365
Location: Mostar

PostPosted: 18.12.2009 09:24    Post subject: Add user to your forum ignore list Reply with quote

A zašto nebi dodao još jednu kolonu u bazu i u nju upisao vrijeme kada je korisnik uradio zadnju akciju na stranici i u sliučaju da nije radio ništa u npr..15 minuta ne prikazivaš ga u listi online korisnika.

_________________
There is no style definition for good music!
Back to top
View user's profile Send private message Visit poster's website Twitter profile
hrvoje_86



Joined: 06 Dec 2006
Posts: 107
Location: Zagreb

PostPosted: 18.12.2009 11:30    Post subject: Add user to your forum ignore list Reply with quote

F34R wrote:
hrvoje_86 wrote:
Pa sam si sad napiso
Code:

onUnload="goodbye()"

// ako korsitiš jquery
function goodbye()
{
$.get("logout.php", { name: "korisnik123123" } );

}

Koje je tvoje pitanje u biti kako pozvati php ?

Pa da...evo probat cu to pa javim dal radi...Hvala
edit:

Ne radi...ne izvrsi logout.php...


Koristiš jquery ?
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
sphx



Joined: 02 Jun 2004
Posts: 109
Location: Split

PostPosted: 18.12.2009 11:41    Post subject: Add user to your forum ignore list Reply with quote

razmisli malo "outside the box".

svaki put kad korisnik otvori novi link, ti to znaš. Dakle pri svakom posjetu potrebno je samo osvježiti tablicu s "online" korisnicima i zapisati timestamp kad je zadnji posjet. Također, brišeš sve retke u toj tablici kojima je timestamp u prošlosti određeni broj sekundi.

primjer za 3 minute:
Code:
$query = 'DELETE FROM `korisnici_online` WHERE (('.time().' - timestamp) > 180)';


dakle tablica u bazi ima polja:

ID_korisnika | timestamp
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
F34R



Joined: 08 Mar 2009
Posts: 30
Location: Metković

PostPosted: 19.12.2009 03:33    Post subject: Add user to your forum ignore list Reply with quote

Hvala svima na pomoci, rijesio sam problem...moze lock Cheers!
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group