Jump to content

stoneheart

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Posts posted by stoneheart

  1. 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);
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.