I’m trying to make a barter-like script. It gets some data about what the user has in his record in the database and I check against another table its value. Then I get the value of the new item the user chooses and then if the user has enough balance (stored in database) after the the former item is refunded, I update the database. However, I’m stuck in the fetching part. This is my code:
[php]//Get cost of chosen item
$query = "SELECT * FROM “.TABLE.” WHERE Item = ".$POST[‘item’] or die(mysql_error());
$recordset = mysql_query($query) or die(mysql_error());
while($result = mysql_fetch_array($recordset)) {
$currentitemcost = $result[‘ItemCost’];
}
//Get cost of current item
$newquery = "SELECT * FROM “.TABLE.” WHERE Item = ".$session->userinfo[‘item’] or die(mysql_error());
$newrecordset = mysql_query($newquery);
while($newresult = mysql_fetch_array($newrecordset)) {
$newitemcost = $newresult[‘ItemCost’];
}[/php]
Note: $session->userinfo[‘item’] stores the current item. Thanks to all who will help.