I'm using Zebra_Form and I want to populate a select box with some values from a query. How do I do this? I have a returnset from MS SQL Server, but I am a newbie and I am baffled about how to frame it into the required array for Zebra_Form.
The below example from the documentation has a hard coded set of values. How can I replace this with my queryset ($stmt printed a little further down) instead?
// single-option select box
$obj = &$form->add('select', 'my_select2');
$obj->add_options(array(
'v1' => 'Value 1',
'v2' => 'Value 2',
'v3' => 'Value 3'
));
//sql code here *
$serverName = "serverName\sqlexpress";
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "select ticketID, ticketName from tickets order by price desc";
$stmt = sqlsrv_query( $conn, $sql);