Jump to content

Recommended Posts

Please help me calculate this according to the "if" condition.

 

$scoreM['newtag'] + $scoreU['newPrice']

 

$SomeVar = 'currentPrice';
$queryU =  "SELECT * FROM db1 WHERE bookprice = '".$SomeVar."'";
$resultU = mysql_query($queryU);
$scoreU = mysql_fetch_assoc($resultU);
echo $scoreU['newPrice'];
echo $scoreU['weeklyScr'];
echo $scoreU['priceX'];

////
$WinVar = 'additionalAmount';
$query =  "SELECT * FROM db2 WHERE booklist = '".$WinVar."'";
$result = mysql_query($query);
$scoreM = mysql_fetch_assoc($result);
echo $scoreM['newtag'];  
echo $scoreM['priceY']; 

if($scoreU['priceX']== $scoreM['priceY'])
{
$udatedValue = ($scoreM['newtag'] - $scoreU['newPrice']);
echo(udatedValue);
}
else{
$udatedValue = ($scoreM['newtag'] + $scoreU['newPrice']);
echo(udatedValue);
}

Link to comment
https://forums.phpfreaks.com/topic/218912-calculation-with-if-statement/
Share on other sites

Thanks jcbones. But the code did not give me the results I wanted. This echos "udatedValue" nothing else.

 

Here's what I'm trying to achieve.

 

I want to check if the $scoreM['newtag'] and $scoreU['newPrice'] are the same.

 

If it is similar

 

then I want to get the difference between $scoreM['newtag'] and $scoreU['newPrice']

 

if it's not similar

 

then I want to get the total between $scoreM['newtag'] and $scoreU['newPrice']

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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