Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

Hi guys, i add this code to cron_fivemins to get randomly the sell prices of drugs. But is missing the way to identify the drugid because all drugs get randomly same price. Someone can help me with this? Thx, and srry for bad english ;p

$chance = rand(50,100);

$db->query("UPDATE drugs SET itmsellprice=$chance");

Edited by badurek
Posted

Im not exactly sure on what you want to accomplish here, a little more info would help a bit. Also you have a fetch_row but its not being used.

Can you please try to explain in a little more detail

Posted

I want get random sell prices for drugs, and i can do this with this code, but all drugs get the same random price. I need each drug get random price. I believe just need to get the id of each drug to work, but i dont know do this.

Posted
$ids = array(1,2,3,4,5,6); //Specific ID's that you want to change the price of
foreach($ids as $id) {
   $chance = mt_rand(50,100);
    $db->query("UPDATE `drugs` SET `itmsellprice`={$chance} WHERE `itmid`=$id"); //I assume the column id `itmid`, as you've adopted the column names from `items`
}
Posted (edited)
$ids = array(1,2,3,4,5,6); //Specific ID's that you want to change the price of
foreach($ids as $id) {
   $chance = mt_rand(50,100);
    $db->query("UPDATE `drugs` SET `itmsellprice`={$chance} WHERE `itmid`=$id"); //I assume the column id `itmid`, as you've adopted the column names from `items`
}

Thats good and all but what about for newbies or for people that forget about the manually entered array and create a new drug?

How about:

$ids = $db->query("select id from from drugs");
foreach($ids as $id) {
   $rand = mt_rand(50, 100);
   $update = $db->query("update drugs set itemsellprice = {$rand} where id = {$id}"),
}
Edited by KyleMassacre
fix a booboo

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