Jump to content

Recommended Posts

I am trying to put a star alongside the players who have donated, when i add this:-

if ($don = "1"){ echo "<font color=gold>*</font>"; } echo "$playername";
$don = mysql_query("SELECT * FROM `players` WHERE `donator` = '$user' LIMIT 1")or die(mysql_error());
$dnum = mysql_numrows($don);

 

I get all the players online with a star next to there name, in the database i have:-

donator  enum('0','1') default being `0`

 

can anyone see my problem please.

 

Regards

 

Gubbins

Link to comment
https://forums.phpfreaks.com/topic/187556-donators/
Share on other sites

order of your code. Try

 

$don = mysql_query("SELECT * FROM `players` WHERE `user` = '$user' LIMIT 1")or die(mysql_error());
$dnum = mysql_numrows($don);
$don=mysql_result($don,0,"donator");
if ($don = "1"){ echo "<font color=gold>*</font>"; } echo "$playername";

 

Also change `user` to whatever you have for user name and the way you were saying i think you had donator in table as either 1 or 0? this means `donator` would never be $user

Link to comment
https://forums.phpfreaks.com/topic/187556-donators/#findComment-990232
Share on other sites

order of your code. Try

 

$don = mysql_query("SELECT * FROM `players` WHERE `user` = '$user' LIMIT 1")or die(mysql_error());
$dnum = mysql_numrows($don);
$don=mysql_result($don,0,"donator");
if ($don = "1"){ echo "<font color=gold>*</font>"; } echo "$playername";

 

Also change `user` to whatever you have for user name and the way you were saying i think you had donator in table as either 1 or 0? this means `donator` would never be $user

 

 

Thank you,

I changed `user` to playername which is what we use and i still get all players online with a star next to there name.

I am sure its almost there....

Link to comment
https://forums.phpfreaks.com/topic/187556-donators/#findComment-990238
Share on other sites

if you post your whole code i might be able to help a bit better

 

 

ummm you have got me there as i don't have any more to this piece, it is part of a larger file but i dont think it right to post the whole file here!

Thank you for your help RaythMistwalker

Link to comment
https://forums.phpfreaks.com/topic/187556-donators/#findComment-990248
Share on other sites

@Rayth can't believe you missed this:

 

if ($don = "1") // should be == or ===

 

Instead of making it so hard to add something so futile do this:

 

echo $don == 1 ? "<span class=\"donator\">$playername</span>" : $playername;

 

Then using simple CSS:

 

.donator:after { content: " *"; color: #0EE; }

Link to comment
https://forums.phpfreaks.com/topic/187556-donators/#findComment-990249
Share on other sites

@Rayth can't believe you missed this:

 

if ($don = "1") // should be == or ===

 

Instead of making it so hard to add something so futile do this:

 

echo $don == 1 ? "<span class=\"donator\">$playername</span>" : $playername;

 

Then using simple CSS:

 

.donator:after { content: " *"; color: #0EE; }

 

Wow thank you very much it worked a treat :)

It always shocks me how one simple command makes such a difference.

Thanks again..

Link to comment
https://forums.phpfreaks.com/topic/187556-donators/#findComment-990252
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.