Php表单在没有空格的页面上生成结果

时间:2013-06-12 13:16:45

标签: php

我的表单有问题。当我按下提交按钮时,结果会向下排6行,但我希望它们在没有空行的形式之后。

我的html文件:

    <center>
    <table width="300">
        <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
            <tr>
                <td width="150"><b>Главница:</b></td>
                <td width="150"><input type="text" style="width: 150px;" maxlength="9" name="number" size="4" /></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td width="150" valign="top"></td>
                <td width="150" align="right"><input style="height: 23px; width: 85px" type="submit" value="Израчунај" name="submit" /></td>
            </tr>
        </form>
    </table>
    </center>

我的计算文件:

   function showForm() {

}


if (empty($_POST['submit'])) {

        showForm();

} else 
{

        if (!is_numeric($_POST['number'])) {

                (int)$_POST['number'] = "error";

        }


        if (empty($_POST['number'])) {

                (int)$_POST['number'] = "error";

        }

        if ($_POST['number'] == "0") {

                (int)$_POST['number'] = "error";

        }


    else 
    {
        $bod = 120;
        $stopaPDV = 0.2;        
        $error = "error";   
        $nula = 0;
        $prva = 250*$bod;   
        $druga = 1000*$bod;
        $treca = 5000*$bod; 
        $cetvrta = 20000*$bod;      
        $peta = 100000*$bod;        


        if (($_POST['number']) == $error) 

        {
            $G = "0,00";
            $ZOI = "0,00";
            $DP = "0,00";
            $NZU = "0,00";
            $ZBIR = "0,00";
            $PDV = "0,00";
            $UKUPNO = "0,00";

                showForm();
            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU</td><br />
                    </tr>  
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV</td><br />
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO</td><br />
                    </tr>                   
                    </table>";              
            echo "<br/><small>Појавила се грешка приликом уношења износа главнице, покушајте поново.</small>";

        }    

        elseif (($_POST['number'])== "0") 

        {
            $G = "0,00";
            $ZOI = "0,00";
            $DP = "0,00";
            $NZU = "0,00";
            $ZBIR = "0,00";
            $PDV = "0,00";
            $UKUPNO = "0,00";

                showForm();
            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU</td><br />
                    </tr>
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV</td><br />
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO</td><br />
                    </tr>                       
                    </table>";              
            echo "<br/><small>Износ главнице мора да буде већи од нуле.</small>";

        }

        elseif (($_POST['number'])<= $prva && ($_POST['number'])> $nula) 

        {

            $G = (int)strip_tags($_POST['number']);
            $G2 = number_format("$G",2,",",".");            
            $ZOI = 25*$bod;
            $ZOI2 = number_format("$ZOI",2,",",".");                        
            $DP = 2.5*$bod;
            $DP2 = number_format("$DP",2,",",".");                                  
            $NZU = 25*$bod*0.5;
            $NZU2 = number_format("$NZU",2,",",".");                                    
            $ZBIR = $ZOI+$DP+$NZU;
            $ZBIR2 = number_format("$ZBIR",2,",",".");                                              
            $PDV = ($ZOI+$DP+$NZU)*$stopaPDV;
            $PDV2 = number_format("$PDV",2,",",".");                                                
            $UKUPNO = $ZBIR+$PDV;           
            $UKUPNO2 = number_format("$UKUPNO",2,",",".");                                              

                showForm();

            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G2</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI2</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU2</td><br />
                    </tr>  
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR2</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO2</td><br />
                    </tr>                       
                    </table>";                  
        }     

        elseif (($_POST['number'])<= $druga && ($_POST['number'])> $prva) 

        {

            $G = (int)strip_tags($_POST['number']);
            $G2 = number_format("$G",2,",",".");            
            $ZOI = 25*$bod+($G-250*$bod)*0.02;
            $ZOI2 = number_format("$ZOI",2,",",".");                        
            $DP = 2.5*$bod*2;
            $DP2 = number_format("$DP",2,",",".");                                  
            $NZU = (25*$bod+($G-250*$bod)*0.06)*0.5;
            $NZU2 = number_format("$NZU",2,",",".");                                    
            $ZBIR = $ZOI+$DP+$NZU;
            $ZBIR2 = number_format("$ZBIR",2,",",".");                                              
            $PDV = ($ZOI+$DP+$NZU)*$stopaPDV;
            $PDV2 = number_format("$PDV",2,",",".");                                                
            $UKUPNO = $ZBIR+$PDV;           
            $UKUPNO2 = number_format("$UKUPNO",2,",",".");                          

                showForm();

            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G2</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI2</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU2</td><br />
                    </tr>    
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR2</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO2</td><br />
                    </tr>                           
                    </table>";                  
        }  

        elseif (($_POST['number'])<= $treca && ($_POST['number'])> $druga) 

        {

            $G = (int)strip_tags($_POST['number']);
            $G2 = number_format("$G",2,",",".");            
            $ZOI = 45*$bod+($G-1000*$bod)*0.01;
            $ZOI2 = number_format("$ZOI",2,",",".");                        
            $DP = 2.5*$bod*2;
            $DP2 = number_format("$DP",2,",",".");                                  
            $NZU = (85*$bod+($G-1000*$bod)*0.05)*0.5;
            $NZU2 = number_format("$NZU",2,",",".");                                    
            $ZBIR = $ZOI+$DP+$NZU;
            $ZBIR2 = number_format("$ZBIR",2,",",".");                                              
            $PDV = ($ZOI+$DP+$NZU)*$stopaPDV;
            $PDV2 = number_format("$PDV",2,",",".");                                                
            $UKUPNO = $ZBIR+$PDV;           
            $UKUPNO2 = number_format("$UKUPNO",2,",",".");                          

                showForm();

            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G2</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI2</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU2</td><br />
                    </tr> 
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR2</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO2</td><br />
                    </tr>                           
                    </table>";                  
        }     

        elseif (($_POST['number'])<= $cetvrta && ($_POST['number'])> $treca) 

        {

            $G = (int)strip_tags($_POST['number']);
            $G2 = number_format("$G",2,",",".");            
            $ZOI = 95*$bod+($G-5000*$bod)*0.005;
            $ZOI2 = number_format("$ZOI",2,",",".");                        
            $DP = 2.5*$bod*2;
            $DP2 = number_format("$DP",2,",",".");                                  
            $NZU = (335*$bod+($G-5000*$bod)*0.04)*0.5;
            $NZU2 = number_format("$NZU",2,",",".");                                            
            $ZBIR = $ZOI+$DP+$NZU;
            $ZBIR2 = number_format("$ZBIR",2,",",".");                                              
            $PDV = ($ZOI+$DP+$NZU)*$stopaPDV;
            $PDV2 = number_format("$PDV",2,",",".");                                                
            $UKUPNO = $ZBIR+$PDV;           
            $UKUPNO2 = number_format("$UKUPNO",2,",",".");                          

                showForm();

            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G2</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI2</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU2</td><br />
                    </tr> 
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR2</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO2</td><br />
                        </td>
                    </tr>                           
                    </table>";                  
        }           

        elseif (($_POST['number'])<= $peta && ($_POST['number'])> $cetvrta) 

        {

            $G = (int)strip_tags($_POST['number']);
            $G2 = number_format("$G",2,",",".");            
            $ZOI = 195*$bod+($G-20000*$bod)*0.002;
            $ZOI2 = number_format("$ZOI",2,",",".");                        
            $DP = 2.5*$bod;
            $DP2 = number_format("$DP",2,",",".");                                  
            $NZU = (1135*$bod+($G-20000*$bod)*0.02)*0.5;
            $NZU2 = number_format("$NZU",2,",",".");                                        
            $ZBIR = $ZOI+$DP+$NZU;
            $ZBIR2 = number_format("$ZBIR",2,",",".");                                              
            $PDV = ($ZOI+$DP+$NZU)*$stopaPDV;
            $PDV2 = number_format("$PDV",2,",",".");                                                
            $UKUPNO = $ZBIR+$PDV;           
            $UKUPNO2 = number_format("$UKUPNO",2,",",".");                          

                showForm();

            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G2</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI2</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP2</td><br />
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU2</td><br />
                    </tr> 
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR2</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV2</td><br />
                        </td>
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO2</td><br />
                    </tr>                           
                    </table>";                  
        }  

        else 

        {

            $G = (int)strip_tags($_POST['number']);
            $G2 = number_format("$G",2,",",".");            
            $ZOI = 395*$bod+($G-100000*$bod)*0.001;
            $ZOI2 = number_format("$ZOI",2,",",".");                        
            $DP = 2.5*$bod;
            $DP2 = number_format("$DP",2,",",".");                                  
            $NZU = (3135*$bod+($G-100000*$bod)*0.01)*0.5;
            $NZU2 = number_format("$NZU",2,",",".");                                        
            $ZBIR = $ZOI+$DP+$NZU;
            $ZBIR2 = number_format("$ZBIR",2,",",".");                                              
            $PDV = ($ZOI+$DP+$NZU)*$stopaPDV;
            $PDV2 = number_format("$PDV",2,",",".");                                                
            $UKUPNO = $ZBIR+$PDV;           
            $UKUPNO2 = number_format("$UKUPNO",2,",",".");                          

                showForm();

            echo "  <table>
                    <tr>
                        <td>Главница:</td>
                        <td>$G2</td>
                    </tr>
                    <tr>
                        <td>Закључак о извршењу:</td>
                        <td>$ZOI2</td><br />
                    </tr>               
                    <tr>
                        <td>Достава писмена:</td>
                        <td>$DP2</td><br />
                        </td>
                    </tr>                                   
                    <tr>
                        <td>Награда за успешност:</td>
                        <td>$NZU2</td><br />
                    </tr> 
                    <tr>
                        <td>Збир:</td>
                        <td>$ZBIR2</td><br />
                    </tr>               
                    <tr>
                        <td>ПДВ:</td>
                        <td>$PDV2</td><br />
                        </td>
                    </tr>                                   
                    <tr>
                        <td>Укупно:</td>
                        <td>$UKUPNO2</td><br />
                    </tr>                           
                    </table>";                  
        }           
    }

}

这是您可以看到我在说什么的页面:http://www.izvrsiteljsu.rs/cirilica/kalkulator.php

希望有人会尽快帮助我, 谢谢。 米兰Lachanski

1 个答案:

答案 0 :(得分:0)

 <tr>
 <td>Закључак о извршењу:</td>
 <td>$ZOI</td>--------------><br />
 </tr>

这是你的6&lt; BR&gt;来自 &lt;之间应该没有任何关系。 / td&gt;和&lt; / tr&gt;