Page 1 of 1

MYSQL QUERY HELP

Posted: 26 Nov 2020, 11:40
by gpmio
I am totally lost as to what the fields need in the MySQL Query (if this is even what I need to be using) so that I can return a field in one Entity into another entity.

I want to enter a client in the projects entity. I am using an Entity field with filters set to "client". I am getting what I want and I can select the client that this project is going to be done for. I also want to return the client's company name as frankly this is what I actually want to be "selectable" in the first place.

Can someone reply with the actual text I would type in each field in the MySQL Query set up fields? Or if I am totally not supposed to use this then how do I return the company name to the projects by milestone entity

Here is the dialog window
dialog window.jpg
Here is the structure (note that I am working in Projects by milestone)
structure.jpg
Here is the fields within the user Entity
parent fields.jpg
And here is the fields in the Projects by milestone Entity
project fields.jpg

Re: MYSQL QUERY HELP

Posted: 27 Nov 2020, 00:24
by antevasin
Try using a Ajax Request field instead.
Change your [500] CO Name field to an Ajax Request and use the following PHP code.

Code: Select all

// as your client is actually a user we will call the ID of your selected client the $user_id
$user_id = [491];
// query the users entity for the company name of the selected client/user
$user_query = db_query("SELECT field_214 FROM app_entity_1 WHERE id = " . $user_id );
// so we don't get an error with no client selected we preset the $value for when the db query returns Null
$value = 'Client is not set';
if ( $user = db_fetch_array( $user_query ) )
{
  // get the users company name
  $value = $user['field_214'];
}
// show the company name on the form
echo $value;
// save the company name to the database
$form_field_value = $value;
You say you are really only interested in the company name so why not use a dropdown populated with company names from a global list? You could use this in the User entity as well instead of your current input field...