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 Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/ 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; Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133503 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. Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133505 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 Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133510 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++) Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133517 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 Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133520 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); ?> Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133523 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 Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133529 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 Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133660 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 . . . Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133661 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? Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133663 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. Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133664 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 Link to comment https://forums.phpfreaks.com/topic/218501-problem-with-php-and-html-together-to-create-a-file/#findComment-1133675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.