Jump to content
MakeWebGames

Quick Help please?


Tyr

Recommended Posts

How would one go about updating multiple differant people in a selected range.

 

for example

 

$db->query("UPDATE gangs SET gangMONEY=gangMONEY+$vault WHERE gangID={$test['gangID']}");

is my query.

I am wanting it to update more than 1 gang.

Link to comment
Share on other sites

Well it's a bit more fickle than that sadly.

Basically I am calling to another table with a JOIN statement and providing the JOINED TABLE matches info in the Gang table it should only update gangs that match the selected join base num_rows

so say 3 out of 5 gangs match up with the Joined table, i want the 3 gangs to be updated on a query.

Link to comment
Share on other sites

Some of the random echo'd text is just me testing queries

 

<?php
include "globals.php";
$_GET['ID']= abs((int) $_GET['ID']);
$_POST['qty']= abs((int) $_POST['qty']);


$query1 = $db->query("SELECT g.`gangID`,t.`gangID`,t.`city`,t.`tax` FROM `gangs` g LEFT JOIN `land` t ON g.`gangID`=t.`gangID` WHERE g.`gangID`={$ir['gang']} AND t.`city`={$ir['location']}");
$test= $db->fetch_row($query1);

$taxquery = $db->query("SELECT `tax` FROM `land` WHERE `city`={$ir['location']}");
$taxation = $db->fetch_row($taxquery);




if(!$_GET['ID'] || !$_POST['qty'])
{
print "Invalid use of file";
}

else if($_POST['qty'] <= 0)
{
print "You have been added to the delete list for trying to cheat the game.";
}

else
{
$q=$db->query("SELECT * FROM items WHERE itmid={$_GET['ID']}");
if(mysql_num_rows($q) == 0)
{
print "Invalid item ID";
}
else
{
$itemd=$db->fetch_row($q);
if($ir['money'] < $itemd['itmbuyprice']*$_POST['qty'])
{
print "You don't have enough money to buy this item!";
$h->endpage();
exit;
}
if($itemd['itmbuyable'] == 0)
{
print "This item can't be bought!";
$h->endpage();
exit;
}



$price=($itemd['itmbuyprice']*$_POST['qty']);
$tax = $price*$taxation['tax'];
$taxprice = $price+$tax;

$counting = $db->query("SELECT gangID FROM land WHERE city={$ir['location']} ORDER BY gangID ASC");
$count = $db->fetch_row($counting);

$test = $db->num_rows($counting);

$vault = $tax/$test;

echo "".$vault."";



if($ir['money'] < $taxprice)
{
echo "You can not afford the Tax on this item";
$h->endpage();
exit;
}

item_add($userid, $_GET['ID'], $_POST['qty']);

while($rr = $db->fetch_row($counting))
{
if(!$db->num_rows($query1))
{
echo "".$rr['gangID']."";
echo "Since Your gang does not own land in this location, you are charged a tax fee of ".$taxation['tax']." percent which goes towards gangs who do own land. Your grand total comes out to ".$taxprice." dollars.";
$db->query("UPDATE users SET money=money-$taxprice WHERE userid=$userid");
$db->query("UPDATE gangs SET gangMONEY=gangMONEY+$vault WHERE gangID={$rr['gangID']}");
$db->query("INSERT INTO itembuylogs VALUES ('', $userid, {$_GET['ID']}, $taxprice, {$_POST['qty']}, unix_timestamp(), '{$ir['username']} bought {$_POST['qty']} {$itemd['itmname']}(s) for {$taxprice}')");
}
}
}

$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 ".number_format($_POST['qty'])." ".stripslashes(htmlentities($itemd['itmname']))."(s) for \$".number_format($price)."";
}

$h->endpage();
?>
Link to comment
Share on other sites

Nay,I was, I managed to fix that had a } in the wrong place

Now it's just updating 1 gang tho >< the last gang.

I set the gangs as a test

2 own land in that city the user i'm buying the item with has no land nor is he in a gang

it takes his money, that tax bit works fine deducting

but where it updates all the gangs a set amount of tax money only the last gang is getting the income

Link to comment
Share on other sites

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