S.Cosmin Posted May 9, 2011 Posted May 9, 2011 Ok guys, i want to change right here from itmname to itmdesc. I have this line, and i want to change there, at "You bought '.$_POST['qty'].' '.$itemd['itmname']..." to be desc not name. $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 '<div class="generalinfo_simple"><font color="green"><center><b><div class="statusbox_ok">You bought '.$_POST['qty'].' '.$itemd['itmname'].' '.(($_POST['qty'] > 1) ? 's' : '').' for '.money_formatter($price).'</div></div></b><center></font>'; ; Quote
W3Theory || Peter Posted May 9, 2011 Posted May 9, 2011 I am a little confused, if I am reading this right. It's pretty easy. Just change the'.$itemd['itmname'].' to '.$itemd['itmdesc'].' ... not sure of the table names. Quote
S.Cosmin Posted May 9, 2011 Author Posted May 9, 2011 I have tried this and doesn't work, that's why i post here...if you guys have another solution... Quote
Kieran-R Posted May 9, 2011 Posted May 9, 2011 Post the query which fetches the item info please. Quote
S.Cosmin Posted May 9, 2011 Author Posted May 9, 2011 (edited) You mean that or? If is not this tell me where i found it. <?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`,`itmname`,`itmbuyable` FROM `items` WHERE `itmid` = {$_GET['ID']}"); if ( $db->num_rows($q) == 0 ) { echo 'Invalid item ID'; } 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 />> <a href="index.php">Go Home</a>'; die($h->endpage()); } if ( $itemd['itmbuyable'] == 0 ) { echo 'This item can\'t be bought!<br />> <a href="index.php">Go Home</a>'; die($h->endpage()); } $grab_shop = $db->query('SELECT `shopID` FROM `shops` WHERE `shopLOCATION` = '.$ir['location']); while ( $list_shop = $db->fetch_row($grab_shop) ) { $shots .= $list_shop['shopID'].','; } $shots .= 0; $result_sID = explode(",", $shots); $grab_sITEM = $db->fetch_row($db->query('SELECT COUNT(`sitemID`) AS `sITEM_CNT` FROM `shopitems` WHERE `sitemSHOP` IN('.$shots.') AND `sitemITEMID` = '.$_GET['ID'])); if ( $grab_sITEM['sITEM_CNT'] == 0 ) { echo 'You can\'t buy items from other cities.<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 '<div class="generalinfo_simple"><font color="green"><center><b><div class="statusbox_ok">You bought '.$_POST['qty'].' '.$itemd['itmdesc'].' '.(($_POST['qty'] > 1) ? 's' : '').' for '.money_formatter($price).'</div></div></b><center></font>'; } } $h->endpage(); ?> Edited May 9, 2011 by S.Cosmin Quote
Nickson Posted May 9, 2011 Posted May 9, 2011 $q = $db->query("SELECT `itmbuyprice`,`itmname`,`itmbuyable` FROM `items` WHERE `itmid` = {$_GET['ID']}"); you see this line (l10), this is the code that selects what information will be later into the $itemd variable. So you'll have to select the itmdesc too change this to (make sure it's the actual correct database field) $q = $db->query("SELECT `itmbuyprice`,`itmname`,`itmdesc`,`itmbuyable` FROM `items` WHERE `itmid` = {$_GET['ID']}"); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.