Jump to content
php.lv forumi

help


FT3

Recommended Posts

Man vjg parveidot kodu

ka lai ustajsa lai ņemtu lietotajus no table users un raditu cik ir online

re kods

<?php
include_once('includes/db_connect.php'); 

$guests = '';
$users = '';

$link = mysql_connect($INFO['sql_host'],$INFO['sql_user'],$INFO['sql_pass']);
mysql_query('use '.$INFO['sql_database'].';');

$now = time()-1050;
$result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where member_id = 0 && running_time > '.$now.';');
$r = mysql_fetch_array($result);
if ($r[0]>0) { $guests = $r[0]; } else { $guests = 0; }

$result = mysql_query('select count(*) from '.$INFO['sql_tbl_prefix'].'sessions where member_id > 0 && running_time > '.$now.';');
$r = mysql_fetch_array($result);
if ($r[0]>0) { $users = $r[0]; } else { $users = 0; }

echo 'Lietotāji ('.$users.'), Viesi ('.$guests.')';

mysql_close($link);
?>

Edited by FT3
Link to comment
Share on other sites

<?
//konekts
$delay = "900";
$delays = time() - $delay;
$useri = mysql_query("SELECT * FROM ibf_members WHERE last_activity >= ".$delays."");
$reg = mysql_num_rows($useri);
$viesi = mysql_query("SELECT * FROM ibf_sessions WHERE member_id = '0' and running_time >= ".$delays."");
$viesi = mysql_num_rows($viesi);
echo '
Viesi: '.$viesi.'<br />
Lietotāji: '.$reg.'<br />';
?>

 

hz, vai iet

Link to comment
Share on other sites

Nu vienkarši nomainot tabulas nosaukumu kodā

 

<?
//konekts
$delay = "900";
$delays = time() - $delay;
$useri = mysql_query("SELECT * FROM TABULA WHERE PEDEJA AKTIVITATE >= ".$delays."");
$reg = mysql_num_rows($useri);
$viesi = mysql_query("SELECT * FROM TABULA WHERE id = '0' and LAIKS >= ".$delays."");
$viesi = mysql_num_rows($viesi);
echo '
Viesi: '.$viesi.'<br />
Lietotāji: '.$reg.'<br />';
?>

Edited by homers
Link to comment
Share on other sites

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\v2\includes\online.php on line 8

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\v2\includes\online.php on line 10
Viesi:
Lietotaji: 

erors

Link to comment
Share on other sites

Vieglākais variants ir šāds:

 

Izveido lietotāja db tabulu online, kad lietotājs ielogojas tabula updeito kolonu online uz vārdu on.

Tad pie online izvēlc šadi:

mysql_query("SELECT * FROM lietotaji WHERE online='on'");

Bet kad izlogojas tabulā updeitojas kolonu online uz vārdu off

Link to comment
Share on other sites

homers: Un ja neizlogojas? Tad visu mūžu rādīsies kā online.

 

DB vajag glabāt pēdējās aktivitātes laiku un vietā kur atlasa online esošos lietotājus atlasīt tos lietotājus, kuriem pēdējās aktivitātes laiks ir pirms, piemēram, ne vēlāks par 5min

 

FT3: aiz kvērija pieliec to ko rakstīju.

Link to comment
Share on other sites

×
×
  • Create New...