helo i’m new here and i was thinking maybe someone can help me solve the problem i have…
i’ve made some php file… and it works good but with one little problem… maybe someone knows where the catch is… i know it is just somewhere but i can’t find it …
in the code belove… you can find that when i want to print out the $shouldd[$i] in the table it prints me like this : 125 125 125 125 125 60 75 75 60 …
but it should be like this: 125 0 0 0 0 60 75 0 60
hope someone knows the answer why does it makes like this …
[b]so again : becouse in the DB in log_table there are only puted values for cluster 1,6,7,9 … there should the result look like this 125 0 0 0 0 60 75 0 60 …
but i get the result: 125 125 125 125 125 60 75 75 60 … when there should be NULL in clusters (2,3,4,5,8) it doesn’t prints 0 but repeates the value from one befor…[/b]
[code]<?php
###############################################
made february 2008
###############################################
include ‘…/library/session_proof.php’;
include ‘…/library/config.php’;
include ‘…/library/opendb.php’;
$today = date(‘D’);
for ( $i = 1; $i <= 9; $i++ ) {
$sqlc1 = “SELECT * FROM input_table WHERE cluster = $i AND week(created_at,1) = week(curdate(),1)”;
$resultc1 = mysql_query($sqlc1) or die (“Napaka v bazi”.mysql_error());
$num_rows_c[$i] = mysql_num_rows($resultc1);
for ( $z = 0; $z <= 6; $z++ ) {
$sqlcc1 = “SELECT should FROM log_table WHERE curdate()-$z >= begin AND curdate()-$z <= end AND id_cluster = $i”;
$resultcc1 = mysql_query($sqlcc1) or die (“Napaka v bazi”.mysql_error());
while($row = mysql_fetch_array($resultcc1) )
{
$should[$z] = $row[‘should’];
}
}
if ( $today == ‘Mon’ ){ $shouldd[$i] = $should[0]; }
if ( $today == ‘Tue’ ){ $shouldd[$i] = $should[0] + $should[1]; }
if ( $today == ‘Wed’ ){ $shouldd[$i] = $should[0] + $should[1] + $should[2]; }
if ( $today == ‘Thu’ ){ $shouldd[$i] = $should[0] + $should[1] + $should[2] + $should[3]; }
if ( $today == ‘Fri’ ){ $shouldd[$i] = $should[0] + $should[1] + $should[2] + $should[3] + $should[4]; }
if ( $today == ‘Sat’ ){ $shouldd[$i] = $should[0] + $should[1] + $should[2] + $should[3] + $should[4] + $should[5]; }
if ( $today == ‘Sun’ ){ $shouldd[$i] = $should[0] + $should[1] + $should[2] + $should[3] + $should[4] + $should[5] + $should[6]; }
}
#echo $shouldd[1]; echo $shouldd[2]; echo $shouldd[3]; echo $shouldd[4]; echo $shouldd[5]; echo $shouldd[6]; echo $shouldd[7]; echo $shouldd[8]; echo $shouldd[9];exit;
$kluster[1] = “Name1”;
$kluster[2] = “Name2”;
$kluster[3] = “Name3”;
$kluster[4] = “Name4”;
$kluster[5] = “Name5”;
$kluster[6] = “Name6”;
$kluster[7] = “Name7”;
$kluster[8] = “Name8”;
$kluster[9] = “Name9”;
?>
Prikaz poteka - Kluster - SOLL IST <?php $time = time(); echo "KLUSTERStatistika za tekoci teden do dana?njega dne:
"; print date("d/m/y", $time); ?>
Kluster | IST | SOLL | RAZLIKA |
"; ?> [/code]