PHP Problem : 8th and 9th entrance of the highway doesn't work

so i have a problem with my PHP code. It's simply the highway calculator, when you entrance in the highway, you receive a ticket with 4 numbers : the first two is the number of the entrance of the highway (0 to 9), and the last two is the vehicle (10 for motorbike, 11 for car and 12 for truck). When i enter the ticket 0711, i have this : Ticket highway. But when i enter the ticket 0811 or 0911, i have this : Ticket highway 2 and i don't know why please guys help me. (i'm very bad in english i'm french so i'm sorry if you don't understand anything).

This is my code :

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        table{
        border-collapse: collapse;
        background-color:lightblue;
        }

        th, td{
        border: 1px solid black;
        padding: 10px;
        }

    </style>
</head>
<body>
<?php
        if (isset($_POST['ticket']))
        {
            $ticket=$_POST['ticket'];
            $xx=substr($ticket,0,-2);
            $yy=substr($ticket,2,4);

            if ($xx==00)
            {
                $km=200;
            }
            elseif ($xx==01)
            {
                $km=180;
            }
            elseif ($xx==02) 
            {
                $km=160;
            }
            elseif ($xx==03) 
            {
                $km=140;
            }
            elseif ($xx==04) 
            {
                $km=120;
            }
            elseif ($xx==05) 
            {
                $km=100;
            }
            elseif ($xx==06) 
            {
                $km=80;
            }
            elseif ($xx==07) 
            {
                $km=60;
            }
            elseif ($xx==08) 
            {
                $km=40;
            }
            elseif ($xx==09) 
            {
                $km=20;
            }

            if ($yy==10)
            {
                $prix=0.05*$km*0.5;
            }
            elseif ($yy==11)
            {
                $prix=0.05*$km*1;
            }
            elseif ($yy==12) 
            {
                $prix=0.05*$km*1.2; 
            }

            echo "type de véhicule : $yy<BR>";
        }
    ?>
    <table>
        <tr>
            <td>
                n° entrĂ©e de pĂ©age : 
            </td>
            <td>
                <?php echo $xx; ?>
            </td>
        </tr>
        <tr>
            <td>
                Kilomètres : 
            </td>
            <td>
                <?php echo "$km kms"; ?>
            </td>
        </tr>
        <tr>
            <td>
                Catégorie véhicule : 
            </td>
            <td>
                <?php 
                    if ($yy==10)
                    {
                        echo "Moto";
                    }
                    elseif ($yy==11) 
                    {
                        echo "Voiture";
                    }
                    elseif ($yy==12) 
                    {
                        echo "Camion";
                    }
                ?>
            </td>
        </tr>
        <tr>
            <td>
                Prix Ă  payer : 
            </td>
            <td>
                <?php echo "$prix €"; ?>
            </td>
        </tr>
    </table>
</body>
</html>


from Recent Questions - Stack Overflow https://ift.tt/31ihgtK
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation