Jump to content

problem with php and html together to create a file


macwadu

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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.8) else printf (' %.2f %%', 100.0000)

 

anyone know how to resolve this problem

 

 

Tanks

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.