Populate grid combo box with database values

I have a PHP file which populates my grid with SQL data. I can manually get a combo box on the grid to populate with values, but not with values from the database. Here is my code:

<?php error_reporting(E_ALL); ini_set('display_errors', '1'); require("../codebase/connector/options_connector.php"); require("../codebase/connector/grid_connector.php"); require("../codebase/connector/db_sqlsrv.php"); $myServer = "ntserver4"; $myUser = "sa"; $myPass = "saPassword"; $myDB = "Scheduler"; //connection to the database $connectionInfo = array( "Database"=>$myDB, "UID"=>$myUser, "PWD"=>$myPass); $conn = sqlsrv_connect( $myServer, $connectionInfo); $gridConn = new GridConnector($conn,"SQLSrv");// connector initialization $gridConn->enable_log("temp.log",true); $gridConn->set_options("Resource1ID", array("1" => "Bob", "2"=>"Sam","3" => "Joe")); $gridConn->render_table("Schedule","ScheduleID","ProjectID, TaskName, Priority, Target, Resource1Hours, Resource1ID, Resource2Hours, Resource2ID, Resource3Hours, Resource3ID, Comments"); ?>

But replacing:
$gridConn->set_options(“Resource1ID”, array(“1” => “Bob”, “2”=>“Sam”,“3” => “Joe”));

With:
$options = new OptionsConnector($conn,“SQLSrv”);
$options->render_table(“Resources”,““,””);
$gridConn->set_options(“Resource1ID”, $options);

is what I think needs to happen, but the combo box does not get populated correctly. I have also tried:

$options->render_table(“Resources”,“ResourceID”,“ResourceID, ResourceName”);

Any suggestions would be appreciated.

Try to use

$options->render_table("Resources","ResourceID","ResourceID(value), ResourceName(label)");

That solved the issue. Thank you very much.

What is the proper format to use “render_sql” rather than “render_table”. I want to use render table to sort the items in the combo box…

I figured it out. Here is the code in case it helps anyone else:

$options->render_sql(“SELECT ResourceID AS value, ResourceInitials AS label FROM Resources ORDER BY ResourceInitials”,“ResourceID”,“ResourceID(value), ResourceInitials(label)”);