I have two tables, a traveler table and a discipline table. The traveler table stores an array under the discipline column (the id's for the disciplines ie: ["43","58"]) and the discipline table has all the names for the disciplines (along with the id and other info for the disciplines). What I am trying to do is echo out the array from the traveler table and call the names from the discipline table, so instead of it looking like ["43"] it would say "discipline name". I have tried various methods such as LEFT JOIN the two tables:
$query ="SELECT t.name, t.disciplines, dis.name as discname
FROM ".TABLEPRIFIX."traveler t
LEFT JOIN ".TABLEPRIFIX."discipline dis ON t.disciplines = dis.id";
$disname = $obj->queryResult($query);
but when I try:
echo $disname['discname'];
I get a "Warning: Illegal string offset 'discname'" error and hit a dead end there.
Next I tried:
<?php $disciplines = (!empty($traveler['disciplines'])) ? (json_decode($traveler['disciplines'])) : array(); ?>
<td><?php echo implode($disciplines); ?></td>
I get the array ["43","58"] to echo out as 4358 but then I get lost on how I would put a space between the two and then get the names for each from the discipline table.
I feel like I am getting close with both of these I just need some guidance/input on what I am doing wrong or what I can look into to get this issue figured out. Thank you for your time reading this and any input and help anyone can provide.