macwadu Posted November 12, 2010 Share Posted November 12, 2010 Hi there, its possible to something like this. <?php $i=0; $MW_Services ="aaaa.php"; $fh_MW_Services = fopen($MW_Services, 'w') or die("can't open file"); $string_MW_Services = "<html><head> </script><span style='padding-left:5px'> MW Services </head> <body> <table> <tr> <td>Teste</td> <td BACKGROUND='images/da.JPG'></td> <td></td> <td><?php for($i;$i>2;$i++){print $i;} ?> </td> </tr> </table> </body>"; fwrite($fh_MW_Services, $string_MW_Services); fclose($fh_MW_Services); ?> my problem is that the code doesnt do the cicle for it only. Tanks Quote Link to comment Share on other sites More sharing options...
Minimeallolla Posted November 12, 2010 Share Posted November 12, 2010 this is what i used when i created files upon registration, im sure you could disect it and use it $username = ($_POST['username']); $filename = "/directory here"; $filenametwo = "/directory here"; $handle = @fopen($filename, 'x+'); $handletwo = @fopen($filenametwo, 'x+'); $content = " <?php include ('write.php') ?>"; $contenttwo = "<center><b>$username</center></b>"; @fwrite($handle, $content)or die; @fwrite($handletwo, $contenttwo)or die; @fclose; Quote Link to comment Share on other sites More sharing options...
Minimeallolla Posted November 12, 2010 Share Posted November 12, 2010 let me know if you still have any problems. Quote Link to comment Share on other sites More sharing options...
macwadu Posted November 12, 2010 Author Share Posted November 12, 2010 that is the same i have like this <?php $i=0; $MW_Services = "aaaa.php"; $fh_MW_Services = fopen($MW_Services, 'w') or die("can't open file"); $string_MW_Services = "<?php for($i;$i>2;$i++){print $i;}?>"; fwrite($fh_MW_Services, $string_MW_Services); fclose($fh_MW_Services); ?> try to put a cicle for inside the tag <?php ?> and not the include that you have and what's the output Quote Link to comment Share on other sites More sharing options...
litebearer Posted November 12, 2010 Share Posted November 12, 2010 Your 'FOR" loop is saying while $i is GREATER than 2 do this; BUT $i is initially set to 0 so the code in the loop is never executed Try this... for ( $i=0; $i<2; $i++) Quote Link to comment Share on other sites More sharing options...
macwadu Posted November 12, 2010 Author Share Posted November 12, 2010 yes my mistake, but thats not all because is not doing the cicle for Quote Link to comment Share on other sites More sharing options...
litebearer Posted November 12, 2010 Share Posted November 12, 2010 Is this what you want? <?php $i=0; $MW_Services = "aaaa.php"; $fh_MW_Services = fopen($MW_Services, 'w') or die("can't open file"); for($i=0;$i<2;$i++){ $string_MW_Services = $string_MW_Services . $i; } fwrite($fh_MW_Services, $string_MW_Services); fclose($fh_MW_Services); ?> Quote Link to comment Share on other sites More sharing options...
macwadu Posted November 12, 2010 Author Share Posted November 12, 2010 More or less Is good but the file only has the last value. You have to put the fwrite inside the cicle <?php $i=0; $MW_Services = "aaaa.php"; $fh_MW_Services = fopen($MW_Services, 'w') or die("can't open file"); for($i=0;$i<2;$i++){ $string_MW_Services = $i; fwrite($fh_MW_Services, $string_MW_Services); } fclose($fh_MW_Services); ?> Thanks for the help Quote Link to comment Share on other sites More sharing options...
macwadu Posted November 12, 2010 Author Share Posted November 12, 2010 Another problem <?php $array_Name_MW = array("CAMEL", "ETU", "PPS", "SMSPcc", "CsPCC"); $i=0; $MW_Services = $PATH_ZABBIX."aaaa.php"; $fh_MW_Services = fopen($MW_Services, 'w') or die("can't open file"); for($i=0;$i<count($array_Name_MW);$i++){ $string_MW_Services =" if ($array_row_Av_MW[$i] < $array_val_MW_ST_red[$i] ) { $STRING_RED } else if ($array_row_Av_MW[$i] >= $array_val_MW_Av_green[$i]) {$STRING_GREEN} else {$STRING_YELLOW} printf (' %.2f %%', $array_row_Av_MW[$i])"; } fwrite($fh_MW_Services, $string_MW_Services); fclose($fh_MW_Services); ?> the if clauses are note working it prints all the if clauses if (100.0000 < 99.8 ) { } else if (100.0000 >= 99. else printf (' %.2f %%', 100.0000) anyone know how to resolve this problem Tanks Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 12, 2010 Share Posted November 12, 2010 You have the conditionals inside quotes, which makes them strings instead of functions. Look at the syntax highlighting, and you can see that something isn't quite right . . . Quote Link to comment Share on other sites More sharing options...
macwadu Posted November 12, 2010 Author Share Posted November 12, 2010 Yes i know but how can i put it in a file witout using the string? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 12, 2010 Share Posted November 12, 2010 It isn't really clear exactly what you're trying to accomplish with that code. Quote Link to comment Share on other sites More sharing options...
macwadu Posted November 13, 2010 Author Share Posted November 13, 2010 I have discovered what i wanted, the thing is this for($i=0;$i<count($array_Name_MW);$i++){ $string_MW_Services =" <tr> <td>$array_Name_MW[$i]</td><td BACKGROUND='images/da.JPG'></td> <td></td><td> <?php if ($array_row_Av_MW[$i] < $array_val_MW_Av_red[$i] ) { echo '$STRING_RED'; } else if ($array_row_Av_MW[$i] >= $array_val_MW_Av_green[$i]) {echo '$STRING_GREEN';} else {echo '$STRING_YELLOW';} ?> <?php printf (' %.2f %%', $array_row_Av_MW[$i]); ?> </td> <td></td> <td> <?php if ($array_row_ST_MW[$i] < $array_val_MW_ST_red[$i]) { echo '$STRING_RED'; } else if ($array_row_ST_MW[$i] > $array_val_MW_ST_green[$i]) {echo '$STRING_GREEN';} else {echo '$STRING_YELLOW';} ?> <?php printf (' %.2f %%', $array_row_ST_MW[$i]); ?> </td> </tr>"; fwrite($fh_MW_Services, $string_MW_Services); } Thanks to all 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.