Jump to content
php.lv forumi

Recommended Posts

Posted (edited)

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
Posted

<?
//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

Posted (edited)

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
Posted

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

Posted

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

Posted

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.

Posted

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AKTIVITATE >= 1256485015' at line 1 

wtf ? :D

×
×
  • Create New...