php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
Big Problem!


 
muitine
19-02-2003, 14:32 
 
Hi, i'm in trouble, and can't figure out what to do next.

I'm a system administrator and i have several users that use my internet connection. what i want to do here, is to let them login with a username and a password and see how many MB they have used this month.

i have the code for the overall MB used during this month, but what i want to do is, to allow them to see how many MB they have used let's say from 9.00 AM till 9.00PM (day time) and then from 9.00PM till 9.00AM (night time)


the output would have to be:
______________
| OVERALL |
|__MB USAGE___|
| DAYTIME |
|__MB USAGE___|
| NIGHT |
|__MB USAGE___|

i have a MySQL database where the data is stored, and i have the php code which picks out the user's that has entered his USERNAME and PASS OVERALL Megabytes used. but how do you pick out those MB that he has used @ day and night?

The login page is login.html when he login's it checks the stat.php and outputs what i want.

the source code of STAT.PHP :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Statistika</title>
</head>
<?
$dbhost="TEST.COM";
$dbuser="TEST";
$dbname="TEST";

if (!$login) {
include "forma";
} elseif (!$passwd) {
include "klaida";
} elseif (paziurim_logina($login, $passwd)) {
print_mb();
} else {
include "klaida";
}
?>
</html>


<?
function paziurim_logina($login, $passwd)
{

$failas = "/var/ipac/etc/passwd";
$duomenys = fopen ($failas, "r");
$index=0;
while (!feof($duomenys)) {
$eilute[$index] = fgetss($duomenys, 100);
list($useris, $slaptazodis, $workdyra, $kazkas) = explode("*", $eilute[$index]);
if ($login==$useris && $passwd==$slaptazodis) {
return 1;
}
$index++;
}
fclose ($duomenys);

return 0;

}
?>

<?
function sql_query($query)
{
global $dbhost, $dbname, $dbuser, $login, $kazkas;
$mysql_access = mysql_connect("$dbhost", "$dbuser") or print ("neprisijungiu");
mysql_select_db("$dbname") or print ("lentos neduoda");
$result = mysql_query($query, $mysql_access) or print ("sh su atsakymu is bazes");
$sk = 0;
while ($row = mysql_fetch_row($result)) {
$kazkass[$sk] = $row;
$sk++;
}
mysql_close($mysql_access);
return $kazkass[0];
}
?>

<?
function print_mb() {
global $dbhost, $dbname, $dbuser, $login, $kazkas;
if ($login == "super") superlogin();
$data_yra = date("Ymd");
$data_men = date("Ym");
$data_men_prad = $data_men . "00";
$laikas_yra = date("His");
$laikas_men_prad = "000000";
// $query = "select round(sum(issiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"$data_men_prad\"";
$query = "select round(sum(issiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"20020501\"";
$issiust = sql_query($query);
$issiusta = $issiust[0];

// $query = "select round(sum(parsiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"$data_men_prad\"";
$query = "select round(sum(parsiusta)/1024/1024) from statistika where vardas=\"$login\" and data>\"20020431\"";
$parsiust = sql_query($query);
$parsiusta = $parsiust[0];
print ("issiusta: $issiusta, parsiusta: $parsiusta");
}
?>

<?
function superlogin() {
print (" super pabaaaiga");
exit;
}
?>



oh, and by the way, i can speak English, but it's not so good too :)

 
muitine
19-02-2003, 14:40 
 
oh, and by the way,

here i get the number of sent and received Megabytes by a user

 
MelloPie
19-02-2003, 14:46 
 
Maybe you should provide some more info about your data, meaning how is it stored how does it look like...
Some rows of your tables might be enough.

 
MoRtAlAn
19-02-2003, 14:50 
 
ehrm...

take a look at the mysql manual:
date and time functions (http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_functions)

date and time types (http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Date_and_time_types)

it depends on the structur of your table (what type is the date column).

or try a select with a between statement.

greetings

 
muitine
19-02-2003, 15:22 
 
ok, let's say i have $morning and $night and the time between $morning and $night would be $day. so, could someone please help me write this simple code?
morning 9.00 AM,
night 9.00 PM.


Alle Zeitangaben in WEZ +2. Es ist jetzt 17:17 Uhr.