Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   User Color in browse (http://www.bvlist.com/showthread.php?t=11870)

elvira 29th November 2018 09:10

User Color in browse
 
Hi something not working so I need any idea

I put this in global.php

PHP Code:

  function get_user_class_color($class)
{
      switch (
$class)
  {
    case 
UC_USER: return "black";

    case 
UC_POWER_USER: return "#f9a200";

    case 
UC_VIP: return "#009F00";

    case 
UC_UPLOADER: return "#6464FF";

    case 
UC_MODERATOR: return "#ff5151";

    case 
UC_ADMINISTRATOR: return "#B000B0";

    case 
UC_SYSOP: return "#2587A7";
    
    case 
UC_STAFFLEADER: return "darkred";

    }
    return 
"";



and add in fuctions.php


PHP Code:

print("<td align=center>" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" $row["owner"] . "><font color=\"#" get_user_class_color($row["class"]) . "\">" htmlspecialchars($row["username"]) . "</font></a>") : "<i>(unknown)</i>") . "</td>\n"); 


and still not work, what I missed, thanks for help

darkalchemy 29th November 2018 09:15

Just a quick glance, you are doubling the '#' sign.

elvira 29th November 2018 09:31

where you see, its only one

darkalchemy 29th November 2018 09:38

case UC_USER: return "#f9a950";

case UC_POWER_USER: return "#f9a200";

case UC_VIP: return "#009F00";

case UC_UPLOADER: return "#6464FF";

case UC_MODERATOR: return "#ff5151";

case UC_ADMINISTRATOR: return "#B000B0";

case UC_SYSOP: return "#2587A7";

case UC_STAFFLEADER: return "#0F6CEE";

Looks like 2 to me.

elvira 29th November 2018 09:46

ok I change this line and not work

PHP Code:

print("<td align=center>" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" $row["owner"] . "><b><font color='" get_user_class_color($row["class"]) . "'> " htmlspecialchars($row['username']) . "</font></b></a>") : "<i>(unknown)</i>") . "</td>\n"); 


darkalchemy 29th November 2018 09:53

You're going to have to be more specific, what doesn't work? What is the exact error, etc?

elvira 29th November 2018 09:58

on browse got same color users not different

darkalchemy 29th November 2018 10:05

Where is row['class'] coming from? Is it from a join to users? Is the query correct? Are the results correct? What color is displayed? What class does that match?

elvira 29th November 2018 10:14

can we go step by step...

Test is User color black

SlaTkis is StaffLeader color black must be darkred

http://shrani.si/f/1r/XI/1ZqmnIci/12.png

darkalchemy 29th November 2018 11:39

I have to guess, because you have not answered the previous questions.

It appears that your query, more specifically your join is flawed. If you look at your error log, you may see that index 'class' does not exist. If you do, simple fix, add the proper join
Code:

LEFT JOIN users ON torrents.owner = users.id
and be sure that you select the class in the query.

But without more information, I am only guessing.

Napon 29th November 2018 12:29

al of this is done in my v2

darkalchemy 29th November 2018 12:43

Quote:

Originally Posted by Napon (Post 52892)
al of this is done in my v2

How does this help?

elvira 29th November 2018 14:28

where I must put class in browse like this one

PHP Code:

    "IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit $class";
    
"categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit  $class";
    
$res sql_query($query) or die(mysql_error()); 


Napon 29th November 2018 15:39

Code:

"IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where$orderby$limit$class";
   
"categories.name AS cat_name, categories.image AS cat_pic, users.username
, users.class FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where$orderby$limit$class";
   
$res = sql_query($query) or die(mysql_error()); 


DND 29th November 2018 16:04

you cannot put get user class color in there that easily

you need to make a different query just for the "Uploader Name" and use format_username function on it
to get color, disable sign, donate sign, warning sign, and other sign that might be
and it doesn't have anything to do with browse.php

darkalchemy 29th November 2018 16:29

Quote:

Originally Posted by Napon (Post 52895)
Code:

"IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where$orderby$limit$class";
   
"categories.name AS cat_name, categories.image AS cat_pic, users.username
, users.class FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where$orderby$limit$class";
   
$res = sql_query($query) or die(mysql_error()); 


This appears to be correct.

@DND you do not need to do a separate query just to get owner, that's the purpose of joins. Using format_username is possible but then you need more than just class and username.

\n";
    }else{
    $htmlout .= "\n";
}
Napon 29th November 2018 16:43

you can also use this in torrenttable_functions in the include
Do not need format_username at all

in my v2 of mysqli this what ive done





Code:

if ($variant == "index")
if ($row['anonymous'] == 'yes') {
    $htmlout.= "

    ".(isset($row["username"]) ? (($row["anonymous"] == "yes" && $CURUSER['class'] < UC_STAFF && $row['owner'] != $CURUSER['id']) ? " ".$lang['torrenttable_anon']."" : " " . htmlspecialchars($row['username']) . "") : "(".$lang["torrenttable_unknown_uploader"].")") . "
   

    " . (isset($row["username"]) ? (" " . htmlspecialchars($row['username']) . "") : "(".$lang["torrenttable_unknown_uploader"].")") . "
   

DND 29th November 2018 16:43

ive done it that way for me and it works.
if it does the job and doesnt put much load on the db..its ok for me
(im not talking about only of color class, but also of other things that are in format_username function)

darkalchemy 29th November 2018 16:48

My code simply requires the userid and format_username handles everything.

Napon 29th November 2018 16:51

Cool so everyone as a option in this thread to do one of them :drink:

elvira 29th November 2018 22:11

ok guys….thanks for help….. only put in browse


PHP Code:

users.class 


and


PHP Code:

$class 


Napon 29th November 2018 22:13

read my thread about this



https://www.bvlist.com/showthread.php?t=11871



https://www.bvlist.com/showthread.php?t=11871

elvira 29th November 2018 22:24

its done

https://i.postimg.cc/zVSjv9SF/11.png

Napon 29th November 2018 22:26

Its easy when you know how mate:drink:

elvira 30th November 2018 01:39

yes if you now but one more thing… how we get user color in Forums

Napon 30th November 2018 01:41

Now this is one big write mate ill get the Code mysqli one of my HD and convert it back to mysql

elvira 30th November 2018 01:46

ok mate Will wait :wave:

BamBam0077 30th November 2018 06:42

What tbdev do you have 08 or 09? Do you have original forums or multilayer forum from u232?

elvira 30th November 2018 12:47

1 Attachment(s)
@BamBam0077, you asking me I have 08

here is my forums.php

Napon 1st December 2018 13:20

BamBam0077


Do not mess my thread up with your crap coding ive seen it and none if it works so keep of my thread Know all Know fuck all

elvira 1st December 2018 18:17

@Napon when you will post a user color for forums

Thanks

Napon 18th August 2019 14:02

2 Attachment(s)
so this is what your looking for this is 5.6 Plateform also ive coder to PHP7 Plateforms 7.2.10 7.1.31 7.2.20 7.2.30


All times are GMT +2. The time now is 00:39.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.