Hello stack community,
For my study i need to understand and learn php. So i made a website and now i have a problem that i can't solve. Within the website there is a shop were 'users' can buy ingame currency with "diamonds". How can i let my users buy something else then currency with their diamonds? I tried multiple ways but it keeps adding the value to the currency instead of the other item.
I tried to find something on the web regarding to this that could help but i can't seem to find anything related to this problem.
Here is the original code:
if($item['currency'] == "")
{
//if isset get buy currency
if(isset($_GET['diamonds']))
{
$id = mysqli_real_escape_string($link, $_GET['diamonds']);
$databaseW = mysqli_query($link, "SELECT * FROM `shop_diamonds` WHERE `id`='$id'") or die(mysqli_error($link));
$itemW = mysqli_fetch_assoc($databaseW);
if(mysqli_num_rows($databaseW) == 1)
{
if($itemW['price'] <= $item['diamonds'])
{
echo("<p>You bought the product!</p>");
mysqli_query($link, "UPDATE `users` SET `cash`=`cash`+'{$itemW['hoeveelheid']}', `diamonds`=`diamonds`-'{$itemW['prijs']}' WHERE `user`='{$_SESSION['users']}'") or die(mysqli_error($link));
}
else
{
echo("<p>You do not have enough diamonds to buy this product</p>");
}
}
else
{
echo("<p>This product does not exist</p>");
}
}
I hope someone could help me with this because i am lost. My question is, how can i let my 'users' buy something else then currency with their daimonds?
If anyone needs more information feel free to ask and i will post it as soon as possible.
Thanks to everyone in regards.