Jump to content

Variable - Variable, isn't working?


3raser

Recommended Posts

<?php require ("style.css") ?>
<center>
<table cellpadding="0" cellspacing="0" id="sharedtable"> 
      <tr class="dblue"> 
        <th colspan="5"><strong>»  Message</strong></th> 
      </tr> 
  <tr class="one"> 

<td class="left">Want to know how much profit you made from your merching? This is the tool for you!</td>
      </tr> 
    </table> 
    <br /> 
   
<table cellpadding="0" cellspacing="0" id="sharedtable"> 
      <tr class="dblue"> 
        <th colspan="5"><strong>»  Calculator</strong></th> 
      </tr> 
  <tr class="one"> 

<td class="left"><form action='index.php' method='POST'>Starting item price <input type='text' name='3' /></td>
<td class="left">Ending price <input type='text' name='4' /></td>
<td class="left">Money you spent <input type='text' name='1' /></td>
<td class="left">Money you got back <input type='text' name='2' /></td>
<td class="left"><input type='submit' value='Calculate'></form></td>
      </tr> 
    </table> 
    <br />    

<?php

$sprice = $_POST['3'];
$eprice = $_POST['4'];
$one = $_POST['1'];
$two = $_POST['2'];

if ($sprice || $eprice || $one || $two) {

}
else

$bamm = $eprice - $sprice;
$total = $one - $two;

echo '<table cellpadding="0" cellspacing="0" id="sharedtable"> 
      <tr class="dblue"> 
        <th colspan="5"><strong>Calculation</strong></th> 
      </tr> 
  <tr class="one"> 

<td class="left">Money gained per item: '.$bamm .'</td>
<td class="left">Total money earned: '. $total .'</td>
      </tr> 
    </table> 
    <br />';  

?>

 

Why isn't $bamm showing up? $total shows up correctly, but the other doesn't. Here's the page: http://merchtool.webege.com/index.php

Link to comment
https://forums.phpfreaks.com/topic/187083-variable-variable-isnt-working/
Share on other sites

Your site seems to be down, but to answer your question - if the second is working, and not the first, then the two variables for $bamm are not actually returning anything. Without the rest of the code, there's no way to be sure, but check that the first 2 variables actually have something.

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.