PaSha Posted February 22, 2008 Share Posted February 22, 2008 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 ... <?php 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"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Prikaz poteka - Kluster - SOLL IST</title> <link href="/style.css" rel="stylesheet" type="text/css" /> </head> <body background="../images/background.png"> <br /><center><img src="../images/logo.jpg" width="200" /><br /><br /> <a href="../main.php">Domov</a> <br /> <?php $time = time(); echo "<b>KLUSTER</b><br><br>Statistika za tekoci teden do današnjega dne: <br>"; print date("d/m/y", $time); ?> <br /><br /></center> <table border="1" cellspacing="1" cellpadding="5" align="center" width="600"> <tr align="center" height="40" bgcolor="#CC0000"> <td width="30%"><b>Kluster</b></td><td width="20%"><b>IST</b></td><td width="20%"><b>SOLL</b></td><td width="30%"><b>RAZLIKA</b></td> </tr> <?php for ($r = 1; $r <= 9; $r++ ) { ?> <tr align="center"> <td><?php echo $kluster[$r]; ?></td><td><font size="4"><b><?php echo $num_rows_c[$r]; ?></b></font></td><td><?php echo $shouldd[$r]; ?></td><td><font size="4"><b><?php echo ($num_rows_c[$r] - $shouldd[$r]); ?></b></font></td> </tr> <?php } ?> </table> <?php echo "<br><center><input type='button' value='Vrni se' onClick='history.go(-1)'></center>"; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 22, 2008 Share Posted February 22, 2008 first of all... this $kluster[1] = 'Name1; $kluster[2] = "Name2"; should be $kluster[1] = "Name1"; $kluster[2] = "Name2"; and second of all.... what??? i have no idea what 125 125 125 125 125 60 75 75 60 or 125 0 0 0 0 60 75 0 60 is meant to be, what are they what are you trying to accomplish here? we might even be able to shorten your code... thanks, Quote Link to comment Share on other sites More sharing options...
PaSha Posted February 22, 2008 Author Share Posted February 22, 2008 first of all... this $kluster[1] = 'Name1; $kluster[2] = "Name2"; should be $kluster[1] = "Name1"; $kluster[2] = "Name2"; and second of all.... what??? i have no idea what 125 125 125 125 125 60 75 75 60 or 125 0 0 0 0 60 75 0 60 is meant to be, what are they what are you trying to accomplish here? we might even be able to shorten your code... thanks, ok that with the name was my mistake when i pasted the code in here so that's not the problem =) ok what i am trying to do is complicated to explain ... but ok i'm gonna try it... i will explain the problem, not the hole issue of code, becouse then i would write half an hour... so in the input table there are located info of every finished product ... and what is imporant is when it was finished (created_at) and in which hall was it made ( clutser) -> there are 9 of them!! and in the log_table ... there are kept info's how many products (should) should have been finished from (begin) to (end) for every hall - cluster. (id_cluster) ->the same like that one above. so i want to display the statistics for this week...how many have been made and how many till curent day should be made and the diference.. so i made it like this ... for ( i = 1 to 9 ) #for every cluster - hall { check the mysql_query and the numer of inputed data (finished products) ... + for ( z=0 to 6) #there are 7 days in a week - for every day bring me the should { select the should from the log_table where curentdate() - z ... and cluster = i ; and so on... } so 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, it doesn't prints 0 but repeates the value from one befor... so hope this is now more explained what the problem is ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.