Jump to content
MakeWebGames

Recommended Posts

Posted

Ok i have added a new colum called dditem in the items table this is set to default 0 but if it is set to 1 it means its a donators item now in itembuy i cannot figure out what the code would be to function it, so if the dditem = 1 and donatordays is below 1 it will echo saying donators items else if if dditem = 1 and donatorday = more than 0 or 1 it will let you purchase the item

 

<?php
include_once (DIRNAME(__FILE__) . '/globals.php');

	$_GET['ID'] = ( isset($_GET['ID'])&&is_numeric($_GET['ID']) )?abs(intval($_GET['ID'])):'';
	$_POST['qty'] = ( isset($_POST['qty'])&&is_numeric($_POST['qty']) )?abs(intval($_POST['qty'])):'';


         if ( empty($_GET['ID']) OR empty($_POST['qty']) ) {
  echo 'Invalid use of file';
         } else {
$q = $db->query("SELECT `itmbuyprice`, `dditem`, `itmname`,`itmbuyable` FROM `items` WHERE `itmid` = {$_GET['ID']} AND ( `loc` = {$ir['location']})");

if ($q['dditem'] == 1 AND ($ir['donatordays'] < 1 )) {
echo"This item is a donators items!";
  die($h->endpage());
}

if ( $db->num_rows($q) == 0 ) {
  echo '<b>This item is not purchasable in this location.</b> ';
} else {
$itemd = $db->fetch_row($q);
  if ( $ir['money'] < ($itemd['itmbuyprice'] * $_POST['qty']) ) {
  echo 'You don\'t have enough money to buy '.$_POST['qty'].' '.$itemd['itmname'].'!<br /><br />> <a href="index.php">Go Home</a>';
  die($h->endpage());
  }
  if ( $itemd['itmbuyable'] == 0 ) {
  echo 'This item can\'t be bought!<br /><br />> <a href="index.php">Go Home</a>';
  die($h->endpage());
  } 

	$price = ($itemd['itmbuyprice'] * $_POST['qty']);
	item_add($userid, $_GET['ID'], $_POST['qty']);
$db->query("UPDATE `users` SET `money` = `money` - $price WHERE `userid` = $userid");
$db->query("INSERT INTO `itembuylogs` VALUES ('', $userid, {$_GET['ID']}, $price, {$_POST['qty']}, unix_timestamp(), '{$ir['username']} bought {$_POST['qty']} {$itemd['itmname']}(s) for {$price}')");
  echo 'You bought '.$_POST['qty'].' <img src="'.$itemd['itmname'].'"> '.(($_POST['qty'] > 1) ? 's' : '').' for '.money_formatter($price).'<br /><br />> <a href="inventory.php">View your Bag</a>';
}
         }


$h->endpage();
?>
Posted
  • Select `dditem` from the items table, with a WHERE clause (`itemid`=$var)
  • Store the value of `dditem` in an array
  • Compare both `dditem` and `donatordays`
  • Manipulate the result

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.   Paste as plain text instead

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