Jump to content
MakeWebGames

Gang Tag on Username


KyleH112

Recommended Posts

I'm trying to add the gang tag of players onto their username in header.php ive tried everything and need some help. I've tried all the $r, $ir combinations, i've tried $tag, $gtag, ['$gtag'] ['gangPREF']. Do I need to call to the database?

Edited by KyleH112
Link to comment
Share on other sites

I was almost tempted to post the way to do this, but then I see an x10 domain.

Kind of can't bring myself to invest time into a game on a free domain as if an owner can't invest in a domain, how can I invest in them?

May want to consider upgrading that.

Link to comment
Share on other sites

left join on gangs with u.id

then collect gangtag and just add $gtag before $_user['username'] echo.

Really guys if you cant collect basic info from a database you shouldn't own a game :(

For, I believe, the first time ever, I feel the need to direct my comments to you, Zettieee.

 

  • Why are we left joining? We just need a join, period.
  • You must have a different version of Mc Code, since Mc Code uses userid and not id.
  • gangtag also doesn't exist. It's gangPREF[ix]
  • Not sure where the $gtag came from, but seems irrelevant to the cause right no.

 

I feel a brief comment like the following would have been shorter, easier to understand AND would have offered more insight.

 

You need to cross reference the gang system for the tag, using a join, then echo the result to the page.

 

Now, if you wanted to be really constructive, you could have done something like;

------------------------------------------------------------------------------------------

First thing first, you need to pull the data from the database by joining the data (Or even an additional query - not what I would suggest).

For an example, if your initial query looked like;

SELECT * FROM users 
JOIN userstats USING (userid)
WHERE userid = x

 

You would change it to something like;

SELECT *, gangPREF FROM users 
JOIN userstats USING (userid)
JOIN gangs ON gang = gangID
WHERE userid = x

 

The above code will call the gang tag (gangPREF) within the query, which could then be used with something along the lines of;

if (strlen($ir['gangPREF'])) {
echo '[' . $ir['gangPREF'] . ']';
}

 

------------------------------------------------------------------------------------------

Of course, why that is par for the course, I'd suggest slight changes.

Since $ir is always defined, I'd probably just do a check with a second query.

 

if ($ir['gang']) {
$sql    = "SELECT gangPREF FROM gangs WHERE gangID = " . $ir['userid'];
// You won't use this, I'm sure. It's a DB class I use.
$result = $db->fetchRow($sql);
echo '[' . $ir['gangPREF'] . ']';
}

 

Why would you do a second call!?

I would assume most people using Mc Code are still using MyIsam databases, which means for the duration of the joined query, both tables are locked.

If you're using InnoDB, that is row level locking, so the hit isn't so bad;

---

I'd also use htmlentities() around the output, with ENT_QUOTES and "UTF-8" as the second and third parameters.

That said, if you're not using global UTF8 encoding, I'd let it use whatever it's using as mixing charsets can cause some pretty poor results (£ signs turning into square blocks etc)

---

With all that said, when making comments such as "If you can't deal with a database, don't run a site", expect a reply such as "If you can't offer advice without substance, stick to the shadows"

Link to comment
Share on other sites

Also sometimes it helps to check your own work, such checking why you would have used $ir or $r in the first place, just because in mccodes those two are the main $vars from two different queries, doesn't mean they are joined with the gang table, so you first want to look at if they are selecting the gang tag or joined to the gang table. If not than you will have to join the gang table to the users table, or go by another method such

example using $ir var....

a=$db->query("SELECT gangPREF FROM gangs WHERE gangID='".$ir['gang']."'");

$b=$db->fetch_row($a);

echo ''.$b['gangPREF'].'';

Link to comment
Share on other sites

Also sometimes it helps to check your own work, such checking why you would have used $ir or $r in the first place, just because in mccodes those two are the main $vars from two different queries, doesn't mean they are joined with the gang table, so you first want to look at if they are selecting the gang tag or joined to the gang table. If not than you will have to join the gang table to the users table, or go by another method such

example using $ir var....

a=$db->query("SELECT gangPREF FROM gangs WHERE gangID='".$ir['gang']."'");

$b=$db->fetch_row($a);

echo ''.$b['gangPREF'].'';

Exactly what this guy said!

Wait, what did this guy just say!?

Link to comment
Share on other sites

  • 2 weeks later...

Thanks guys, I got it working.

The x10 domain is of my first game I made, kind of a learning experience while I was in Iraq, I had a lot of down time so I decided to start a new hobby. I'm currently working on a new project and im using hosting24.

 

I was almost tempted to post the way to do this, but then I see an x10 domain.

Kind of can't bring myself to invest time into a game on a free domain as if an owner can't invest in a domain, how can I invest in them?

May want to consider upgrading that.

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