Jump to content

need help with if statment


jccpweb

Recommended Posts

ok so here it is... what im trying to do is like a bidding thing like ebay. what im having problem is with this i have an IF statement  that said if $bid (which is what they just put in) is lower higher than $LowetBid which is the lowest bid saved in the DB. but it wont work like the if statement does not do what it suppose to. when i put the lower bid it doesnt do the fuction its suppose to it basically ignores it... here is the code

 

<?
require_once("includes/CompvalidUserCheck.php");
?>
<?php 
echo $username;
echo $ProductID = $_SESSION['ProductID'];
echo $Bid = ($_POST['Bid']);

$dbHost = "###########
$dbUser = "#######";
$dbPass = "#######";
$dbDatabase = "######";

$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");

mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");

$result=mysql_query("select * from PRODUCTS,COMPANYS where PRODUCTS.ProductID='$ProductID' and COMPANYS.Email='$username'", $db);

while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table

$LowestBid=$row['LowestBid'];
$CompanyID=$row['CompanyID'];
$CompanyName=$row['CompanyName'];
}

//if statement starts here

if ($Bid>$LowestBid-1)
{echo "enterlower";



}
else 
{

$con2 = mysql_connect("$dbHost", "$dbUser", "$dbPass");

if (!$con2)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($dbDatabase, $con2);

$sql2=("UPDATE PRODUCTS SET LowestBid = '$Bid', LowestBidCompany = '$CompanyName' where ProductID='$ProductID' "); 

if (!mysql_query($sql2,$con2))
  {
  die('Error: ' . mysql_error());
  
  }
  




$con4 = mysql_connect("$dbHost", "$dbUser", "$dbPass");

if (!$con4)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db($dbDatabase, $con4);

$sql4=("INSERT INTO CompanyBids (CompanyID, ProductID, Bid) VALUES ('$CompanyID','$ProductID','$Bid') "); 

if (!mysql_query($sql4,$con4))
  {
  die('Error: ' . mysql_error());
  }
header( "Location:companyarea.php" );


}
?>

 

 

help me please!!!

Link to comment
https://forums.phpfreaks.com/topic/149566-need-help-with-if-statment/
Share on other sites

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.