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

 

 

 

 

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;

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

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);
?>

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

 

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

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 . . .

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  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.