Adding array information based on row information from mysql

QuestionsAdding array information based on row information from mysql
Tim Moore asked 2 years ago

View post on imgur.com

I have an array full fo windows directory information, and i would like to fill a few columns with that array information based on the “row” information. I would hope the answer is simple, but i am having a heck of a time figuring it out.

// DL DWG NUM

$col = array();
$col[“title”] = “DWG NO.”;
$col[“name”] = “dl_dwg_num”;
$col[“hidden”] = false;
$col[“export”] = true;
$col[“editable”] = true;
$col[“editoptions”][“defaultValue”] = $q_info2[‘unit_number’] . “-“; //DEFAULT TEXT
$col[“width”] = “100”;
$cols[] = $col;

$key = array_search(‘{dl_dwg_num}’, array_column($files, ‘db_dl_name’));

// FILE REV NUMBER

$col = array();
$col[“title”] = “File Rev Letter”;
$col[“name”] = “File_Rev_Letter”;
$col[“hidden”] = false;
$col[“export”] = true;
$col[“editable”] = true;
$col[“default”] = $files[$key][‘rev_letter’];
$col[“width”] = “100”;
$cols[] = $col;

I need to read the colunm  “dl_dwg_num” and search an array – and place that information from the array in column  “File_Rev_Letter”

View post on imgur.com

Please help

Thanks in advance,

Tim

 

2 Answers
Abu Ghufran Staff answered 2 years ago

Hi,

In the column options of File_Rev_Letter, You can add following:

$col["on_data_display"] = array("display_array_info","");

function display_array_info($data)
{
    global $files;
    $key = array_search($data["dl_dwg_num"], array_column($files, 'db_dl_name'));
    return $files[$key]["rev_letter"];
}

You can remove the $col[“default”]=… and $key=… lines.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Tim Moore answered 2 years ago

I was close :/

Perfect solution. Thanks Abu! Worked perfectly!

Your Answer

12 + 13 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?