Hi! I have a colour palette on my site and on the custom pet screen I display what the current selected colour is for the various parts. That works well but I'd like to display the hex name from the adopts_colour_palette table instead of just the hex value from the adopts_custom table.
You can see that all the colours have the hex and then their name next to them, but the top option (the current registered value in the DB) is just the hex. I'm not sure how to join the customs table (which stores the hex of each colour) and the colour_palette table (which stored both hex and name) to fetch the colour name depending on what the current hex is.
Currently this is how I get the selected colours:
Then to fetch it for each specific dropdown (there are lots of customisation options so there are a few lol) I use:
I know you can use something like this:
But I'm unsure how to finish it. I also assume you'd need to repeat it for each instance you want to fetch, like body_colour1, body_colour2, etc. But if I'm wrong about that and there is a way to do it without needing like 20 lines of code then I'm all ears lol
Thanks~
You can see that all the colours have the hex and then their name next to them, but the top option (the current registered value in the DB) is just the hex. I'm not sure how to join the customs table (which stores the hex of each colour) and the colour_palette table (which stored both hex and name) to fetch the colour name depending on what the current hex is.
Currently this is how I get the selected colours:
PHP:
$selected = $mysidia->db->select("custom", array(), "uid='{$mysidia->user->getID()}' && species='cat_bean'")->fetchObject();
Then to fetch it for each specific dropdown (there are lots of customisation options so there are a few lol) I use:
PHP:
{$selected->body_colour1},
{$selected->nose_colour}, etc
I know you can use something like this:
PHP:
$body_colour1 = $mysidia->db->join("custom", "{$selected->body_colour1}.hex = colour_palette.hex")
->select("colour_palette", [], "");
But I'm unsure how to finish it. I also assume you'd need to repeat it for each instance you want to fetch, like body_colour1, body_colour2, etc. But if I'm wrong about that and there is a way to do it without needing like 20 lines of code then I'm all ears lol
Thanks~