Hello world,
First let me say great job I really like phpMyEdit. That said I am starting to feel stupid. I have been working on trying to get a join to work for the last few days.
Here is my situation (like many others)
2 tables
table 1: accounts_cstm with 11 (eleven) columns with a unique id named id_c
table 2: accounts with 15 columns including a unique ID named id and a name column called name.
I want to list some data from accounts_cstm (this works great "out of the box")but show the name of the account and not the id_c of the account. It is also a link to the web app this is pulling data from. The link works and goes to the correct page I just want it to show the "name" and not the id in the displayed table.
The name lives in accounts.name and accounts.id is the same id as accounts_cstm.id_c
How can I do a join (not sure a join is the best way) to display the account name from account table instead of the accounts id from accounts_cstm.id_c
Here is my code that shows the account_cstm id_c (the _c is for custom) this works but does not show the name. There is no JOIN in this example, how would I add it. I looked at the documentation and it just made me feel dumb (because I have no idea what the doc was trying to teach me it is IMHO too vague)
I found others having the same problem, some posts had answers, others looked like they did but the "answer posts" mostly by Doug did not show.
Any help or examples would be greatly appreciated.
$opts['fdd']['id_c'] = array(
'name' => 'Customer Sugar ID LINK',
'select' => 'T',
'maxlen' => 36,
'sort' => true,
'URL' => 'http://ourdomain.lan/crm/index.php?module=Accounts&action=DetailView&record=$value',
'URLtarget' => '_blank'
);
To help clear things up in the above code I have the URL and at the end have $value (I want the current value to stay the same I just want the link to show the account name and not the ID and account name is not in the same table.
What do I need to add to make it show data from a different table but look at the same ID number to get the NAME I want displayed.
PS I did read the html documentation and searched the forum and read way to much. I am now more confused than when I started.
Thanks!!
|
First off, see if the following will display the name, and worry about making it a link later, in order to keep it simple.
| Kód: |
$opts['fdd']['id_c'] = array(
'default' => 'default',
'maxlen' => 10,
'name' => 'Name',
'select' => 'T',
'sort' => true,
'values' => array(
'table' => 'accounts',
'column' => 'id',
'description' => array(
'columns' => array('0' => 'name')
)
)
); |
|
Thank you Doug! I tried your code and it worked, at least as well as one I did last night. However I can not seem to get the URL to pass properly. Same problem I had with the code I did based on another post I saw about joins and virtual tables. It did the same thing but was a lot more code (I like your simple code much better)
Here is what I tried
I put the below code into the code you supplied but the link is wrong. It shows the name of the account and not the id in the URL
'URL' => 'http://server.ourdomain.lan/crm/index.php?module=Accounts&action=DetailView&record=$value',
'URLtarget' => '_blank',
Total chunk of code is
//code from Doug
$opts['fdd']['id_c'] = array(
'default' => 'default',
'maxlen' => 10,
'name' => 'Name',
'select' => 'T',
'sort' => true,
'URL' => 'http://server.ourdomain.lan/crm/index.php?module=Accounts&action=DetailView&record=$value',
'URLtarget' => '_blank',
'values' => array(
'table' => 'accounts',
'column' => 'id',
'description' => array(
'columns' => array('0' => 'name')
)
)
);
What I expected was a URL like http://server.ourdomain.lan/crm/index.php?module=Accounts&action=DetailView&record=21485e17-816c-aa0b-969a-43b4429034da
(this is a real id and works as a link)
and not http://server.ourdomain.lan/crm/index.php?module=Accounts&action=DetailView&record=F5 Networks
(this is a real name that matches the id or id_c but does not link right; will not open the correct web page)
Of course it will not open the correct page. Is there a way to use a variable like $value (I know $value is the name now) but it is the id_c or id (ether table id will work) and not the name? Or did I put the 'URL' into the wrong location within the supplied code?
I will look at the documentation again and see what I come up with.
Again thanks for your expert knowledge and assistance Doug!
|