PHP我的数学不工作,我的变量显示0,但它是别的东西


PHP my math doesnt work and my vairable shows 0 but it is something else

所以我的问题是我在脚本开始时设置了变量,后来在脚本中我需要该变量做一些数学,所以它知道它是否有钱买东西,如果它没有钱买物品。这是我的脚本

错误一直显示在脚本的底部。

    $user = 'Ramon';
// get integer data from url
$removeslash = "/xampp/";
$actual_link3 = "$_SERVER[REQUEST_URI]";
$actual_link2 = str_replace($removeslash,"",$actual_link3);
$actual_link = str_replace(".php","",$actual_link2);
echo $actual_link;
// connect to mysql database
$conn = mysqli_connect($host,$username,$password, $database);
if (!$conn) {
    die('Not connected : ' . mysqli_error());
}
$result = mysqli_query($conn, "SELECT * FROM Bedrijf WHERE ID='".$actual_link."'");
$row = mysqli_fetch_array($result);
$NaamBedrijf = $row['Name'];
$WorthNow = $row['WorthNow'];
$result2 = mysqli_query($conn, "SELECT * FROM Users WHERE Username='".$user."'");
$row2 = mysqli_fetch_array($result2);
$Aandelen = $row2['Shares'.$actual_link];
$Money = $row2['Money'];
echo "IK HRB NU".$Aandelen;
//Waarde aandelen berkenen
$WaardePort = $Aandelen * $WorthNow;
//Geld formateren van 1293384 naar $1,293,384.00
setlocale(LC_MONETARY, 'en_US');
$MoneyFOR = money_format('%(#10n', $Money) . "'n";
$WaardePort = money_format('%(#10n', $WaardePort) . "'n";
$WaardeNU = money_format('%(#10n', $WorthNow) . "'n";
echo "AANDELEN:".$Aandelen;
echo "<html>
<head>
<title>Beurs</title>
<link rel='stylesheet' type='text/css' href='index.css'/>
</head>
<body>
<center>
<table>
<tr>
<td width='992px'>
<p class='ingelogd'>Je bent ingelogd Als ".$user."</p>
</td>
</tr>
<tr>
<td width='992px'>
<p>Er staat ".$MoneyFOR." Dollar op je bank.</p>
</td>
</tr>
</table><br/>
<table>
<tr>
<td id='Title' width='992px'>Je Kunt Informatie zien over je aandelen en aandelen verkopen/kopen.</td>
</tr>
</table>
<table width='1000px'>
  <tr>
    <td>".$NaamBedrijf."</td>
    <td>".$WaardeNu."</td>
    <td>".$Aandelen."</td>
  </tr>
  <tr>
    <form>
    <td>Kopen of Verkopen?</td>
    <td>
    <input type='radio' name='1' value='1'>Verkopen</input>
    <input type='radio' name='2' value='2'>Kopen</input><br/>
    </td>
    <td>Aantal andelen:<input style='width:85px;' type='text' name='Totaal'/><input type='submit' name='submit' value='Koop/Verkoop'/></td>
    </form>
  </tr>
</table>
<table>
<tr>
<td width='992px'><label>Je aandelen zijn ".$WaardePort." Dollar Waard.</label><input type='submit' name='back' value='Ga Terug naar overzicht'/></td>
</tr>
</table>
</center>
</body>
</html>";
echo "AANDELEN:".$Aandelen;
if($_GET){
    if(isset($_GET['submit'])){
    if(isset($_GET['1'])){
        echo "Aandelen totaal:".$_GET['Totaal'];
        echo "Hoeveel aandelen heb ik: ".$Aandelen;
        if (!$_GET['Totaal'] > $Aandelen) { //ERROR IS HERE AND BELOW
            echo "<center><p style='color:red; font-weight:bold;'>je hebt niet zoveel andelen!</p></center>";
        }else{
        $jekrijgt = $WorthNow * $_GET['Totaal'];
            $Aandelen = $Aandelen - $_GET['Totaal'];
            $Money = $jekrijgt + $Money;
            echo "Je hebt ".$_GET['Totaal']." Aandelen Verkocht Voor: ".$Money;
            echo $Aandelen;
        }
    }else{
        echo "BUY"; 
    }
    }
}
?>

解释!

当在If语句之前回显变量aandelen时,它显示得很好,但是当我试图做一些数学来使它没有那么多股份(aandelen)时,它会回显你没有那么多股份。’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’

查看出错的地方请查看http://wirechat.net16.net/xampp/5.php

!$_GET['Totall']>操作符之前被处理。

这意味着它只会(在数字上)为零(如果Totall为真),或者为一(如果Totall为空或为零)。

否定>的正确方法是用<=代替。

if( $_GET['Totaal'] <= $Aandelen)