Jump to content
MakeWebGames

Gang query help


SHAD

Recommended Posts

hey, i have tried but can't come up with a query that would check if user is the gang presendet and allow him to update the coloums ( gangRESPECT and gangUPDATE) .

Can anyone help please?

<?php
include (DIRNAME(__FILE__) ."/globals.php");


if(!$gangdata['gangPRESIDENT'])
{
echo'Only the gang president can perform this action.';
$h->endpage();
exit;
}
else
{
if($gangdata['gangRESPECT']>=150)
{
mysql_query("UPDATE `gangs` SET `gangUPDATE` = 1, `gangRESPECT` - 150 ' WHERE `userid` = {gangdata['gangPRESIDENT']}");
echo' Congratulation, Your gang now has been updated';
}
else
{
echo'you gang does not have enough respect .';
}
}
$h->endpage();
?>
Link to comment
Share on other sites

Well, this is simple.

Try:

<?php
 include(dirname(__FILE__) . "/globals.php");


 if ($gangdata['gangPRESIDENT'] !== $ir['userid']) {
     echo 'Only the gang president can perform this action.';
     $h->endpage();
     exit;
 } else {
     if ($gangdata['gangRESPECT'] >= 150) {
         mysql_query("UPDATE `gangs` SET `gangUPDATE` = 1, `gangRESPECT` - 150 ' WHERE `userid` = {gangdata['gangPRESIDENT']}");
         echo ' Congratulation, Your gang now has been updated';
     } else {
         echo 'you gang does not have enough respect .';
     }
 }
 $h->endpage();
?>
Link to comment
Share on other sites

Well, this is simple.

Try:

<?php
 include(dirname(__FILE__) . "/globals.php");


 if ($gangdata['gangPRESIDENT'] !== $ir['userid']) {
     echo 'Only the gang president can perform this action.';
     $h->endpage();
     exit;
 } else {
     if ($gangdata['gangRESPECT'] >= 150) {
         mysql_query("UPDATE `gangs` SET `gangUPDATE` = 1, `gangRESPECT` - 150 ' WHERE `userid` = {gangdata['gangPRESIDENT']}");
         echo ' Congratulation, Your gang now has been updated';
     } else {
         echo 'you gang does not have enough respect .';
     }
 }
 $h->endpage();
?>

that wont work

look that the query...

mysql_query("UPDATE `gangs` SET `gangUPDATE` = 1, `gangRESPECT` - 150 ' WHERE `userid` = {gangdata['gangPRESIDENT']}");

 

it doesnt select their gang and if it did, it reset their gang respect to -150 instead of removing 150.

its meant to be

mysql_query("UPDATE `gangs` SET `gangUPDATE` = `gangUPDADE` + 1, `gangRESPECT` = `gangRESPECT` - 150 ' WHERE `gangID` = {$ir['gang']}");

 

unless you want it so you can only upgrade once then you have to add this. to like under globals.php bit

if(gangdata['gangUPDATE'] == 1)
{
echo 'You gang is already upgraded. You cant upgrade it anymore.
[url="yourgang.php"]Go Back[/url]';
$h->endpage();
exit();
}

 

also what about if the gang has 151 respect and upgrades they will be stuck with 1 respect and if they are in a war and 1 member gets attacks thats bi bi to gang

think about it, do it with like at least 25 or more of the respect required to upgrade so

if ($gangdata['gangRESPECT'] >= 175) {

 

then there gang wouldnt get destroyed so easierly

Link to comment
Share on other sites

try this, not tested and im not professional nither so... it might not work...

if you get a error remove a } at bottom of script

<?php
include (DIRNAME(__FILE__) ."/globals.php");
if($gangdata['gangRESPECT'] < 175)
{
echo'You need at least 175 respect or more for this upgrade.

Please come back once you have the required gang respect.';
$h->endpage();
exit();
}
if(!$gangdata['gangPRESIDENT'])
{
echo'Only the gang president can perform this action.';
$h->endpage();
exit;
}
else
{
if($gangdata['gangRESPECT']>=175)
{
mysql_query("UPDATE `gangs` SET `gangUPDATE` = `gangUPDADE` + 1, `gangRESPECT` = `gangRESPECT` - 150 ' WHERE `gangID` = {$ir['gang']}");
echo' Congratulation, Your gang now has been updated';
}
}
$h->endpage();
?>
Link to comment
Share on other sites

  • 3 weeks later...

Well said Nic. I think I might be able to explain some of this myself. NOW! I ain't so good/good at this so, I might be wrong. But some parts I have seen in recent mods of some people.

1:

[mysql]`gangUPDATE` = 1[/mysql]

Well, as I understand of SQL, your saying for the database to = 1 Gang? As nic posted above:

[mysql]`gangUPDATE` = `gangUPDADE` + 1[/mysql]

Your Adding(+) the gang update by 1. Im not sure why `gangUPDATE` is needed twice, but lets not argue. :P

2:

[mysql]WHERE `userid`[/mysql]

Erm... gangs? Lol. Wrong DB.. Lol. Yet again like nic posted.

[mysql]`gangID` = {$ir['gang']}[/mysql]

Is the right DB for using for. Although, I'm not to sure on this. but I think ( $r ) Is used for that USERS gang. And I think ( $ir ) for for everyonee gang. Like, displying Gangs in the gang.php file. But, I might be wrong. Please correct me if I am right. :)

Link to comment
Share on other sites

I think ( $r ) Is used for that USERS gang. And I think ( $ir ) for for everyonee gang. Like, displying Gangs in the gang.php file. But, I might be wrong. Please correct me if I am right. :)

no... $r isnt for users gang lol

$r = person your viewing for example,

viewuser.php (someones profile, $r view their information like money and etc ($r['money']))

or

userlist.php (list of players, $r view their username ($r['username']) or gender ($r['gender']))

and etc...

$ir = you, wherever $ir is thats selecting your userid's information from the database.

not quite sure how to explain it fully but the gang stuff is $gangdata but for selecting like a gang you have to do something like this

SELECT FROM gangs (for users table it be "SELECT FROM users")

which you can see its selecting information from the database section gangs

and in that section there be a spot called

gangID which is the main part of the gangs SQL (gangs ID)

and to grab the players gang they have to do this

gangID = {$ir['gang']}

as you can see... $ir['gang'] is there and the player that is viewing that page it will select the the gangID on that players gangID number in the database

as for example, say mines 17, it select the gangID 17 from the gangs database section so it be like

gangID = 17

so the SQL query will be like

mysql_query("UPDATE gangs SET blah=blah+1 WHERE gangID=17");

and that will update that gangs ID's whatever its set to update.

dont worry i used to ask for help and crap all the time still do sometimes but not as much as i used too...

everyone said stop asking for help all the time and try learning how to code which i was trying to do in the first place lol, but i guess i wasnt really showing it fully... but i cant learn quick lol, took me while to know as much i know by reading like Illisions and danny656's mods and other peoples, as im kinda a copy and learn type person lol. i cant learn stuff from like

w3schools.com or php.net

those sites are confusing for me.

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