Gubbins Posted January 7, 2010 Share Posted January 7, 2010 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 More sharing options...
RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 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 More sharing options...
Gubbins Posted January 7, 2010 Author Share Posted January 7, 2010 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 More sharing options...
RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 if you post your whole code i might be able to help a bit better Link to comment https://forums.phpfreaks.com/topic/187556-donators/#findComment-990246 Share on other sites More sharing options...
Gubbins Posted January 7, 2010 Author Share Posted January 7, 2010 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 More sharing options...
ignace Posted January 7, 2010 Share Posted January 7, 2010 @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 More sharing options...
Gubbins Posted January 7, 2010 Author Share Posted January 7, 2010 @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 More sharing options...
RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 woops lol. i always miss the small things >< thanks ignace Link to comment https://forums.phpfreaks.com/topic/187556-donators/#findComment-990254 Share on other sites More sharing options...
Mchl Posted January 7, 2010 Share Posted January 7, 2010 Where do you get a list of players to display? Perhaps you should get donator status in the same query? Would be a lot more efficient. Link to comment https://forums.phpfreaks.com/topic/187556-donators/#findComment-990277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.